Skip to content

fix(deps): remove tempy #7223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 3 additions & 110 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@
"readdirp": "4.1.2",
"semver": "7.7.1",
"source-map-support": "0.5.21",
"tempy": "3.1.0",
"terminal-link": "4.0.0",
"toml": "3.0.0",
"tomlify-j0.4": "3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/functions/runtimes/go/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { dirname, extname } from 'path'
import { platform } from 'process'

import type { LambdaEvent } from 'lambda-local'
import { temporaryFile } from 'tempy'

import type {
BaseBuildResult,
Expand All @@ -13,6 +12,7 @@ import type {
} from '../index.js'
import execa from '../../../../utils/execa.js'
import { runFunctionsProxy } from '../../local-proxy.js'
import { temporaryFile } from '../../../../utils/temporary-file.js'

const isWindows = platform === 'win32'

Expand Down
2 changes: 1 addition & 1 deletion src/utils/deploy/deploy-site.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { rm } from 'fs/promises'

import cleanDeep from 'clean-deep'
import { temporaryDirectory } from 'tempy'

import BaseCommand from '../../commands/base-command.js'
import { type $TSFixMe } from '../../commands/types.js'
Expand All @@ -21,6 +20,7 @@ import hashFns from './hash-fns.js'
import uploadFiles from './upload-files.js'
import { getUploadList, waitForDeploy, waitForDiff } from './util.js'
import type { DeployEvent } from './status-cb.js'
import { temporaryDirectory } from '../temporary-file.js'

export type { DeployEvent }

Expand Down
19 changes: 19 additions & 0 deletions src/utils/temporary-file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as path from 'node:path'
import * as os from 'node:os'
import * as crypto from 'node:crypto'
import * as fs from 'node:fs'

const uniqueString = () => crypto.randomBytes(8).toString('hex')

const tempDir = os.tmpdir()

export function temporaryFile({ extension }: { extension?: string } = {}): string {
const baseName = uniqueString()
const ext = extension ? '.' + extension.replace(/^\./, '') : ''
return path.join(tempDir, baseName + ext)
}

export function temporaryDirectory({ prefix = '' } = {}): string {
const directory = fs.mkdtempSync(`${tempDir}${path.sep}${prefix}`)
return directory
}
2 changes: 1 addition & 1 deletion tests/integration/commands/blobs/blobs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { env } from 'process'
import { ListResultBlob } from '@netlify/blobs'
import { BlobsServer } from '@netlify/blobs/server'
import httpProxy from 'http-proxy'
import { temporaryDirectory } from 'tempy'
import { afterAll, beforeAll, describe, expect, test } from 'vitest'

import { FixtureTestContext, setupFixtureTests } from '../../utils/fixture.js'
import { Route } from '../../utils/mock-api-vitest.js'
import { temporaryDirectory } from '../../../../src/utils/temporary-file.js'

const blobsProxy = httpProxy.createProxyServer({})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { describe, test, beforeAll, afterAll } from 'vitest'
import fs from 'fs'
import { rm } from 'fs/promises'
import { temporaryDirectory } from 'tempy'
import { handleQuestions, CONFIRM, DOWN, NO, answerWithValue } from '../../utils/handle-questions.js'
import execa from 'execa'
import { cliPath } from '../../utils/cli-path.js'
import { join } from 'path'
import { TABTAB_CONFIG_LINE, AUTOLOAD_COMPINIT } from '../../../../src/utils/command-helpers.js'
import { temporaryDirectory } from '../../../../src/utils/temporary-file.js'

describe('completion:install command', () => {
let tempDir: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { describe, test } from 'vitest'

import { withDevServer } from '../../utils/dev-server.js'
import { withSiteBuilder } from '../../utils/site-builder.js'
import { temporaryDirectory } from '../../../../src/utils/temporary-file.js'

describe.concurrent('commands/dev-forms-and-redirects', () => {
test('should return 404 when redirecting to a non existing function', async (t) => {
Expand Down Expand Up @@ -427,7 +428,6 @@ describe.concurrent('commands/dev-forms-and-redirects', () => {
};
`

const { temporaryDirectory } = await import('tempy')
const pluginDirectory = temporaryDirectory()

await fs.writeFile(path.join(pluginDirectory, 'manifest.yml'), pluginManifest)
Expand Down Expand Up @@ -486,7 +486,6 @@ describe.concurrent('commands/dev-forms-and-redirects', () => {
};
`

const { temporaryDirectory } = await import('tempy')
const pluginDirectory = temporaryDirectory()

await fs.writeFile(path.join(pluginDirectory, 'manifest.yml'), pluginManifest)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/utils/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { join } from 'path'
import { fileURLToPath } from 'url'

import type { NodeOptions } from 'execa'
import { temporaryDirectory } from 'tempy'
import { afterAll, afterEach, beforeAll, beforeEach, describe } from 'vitest'

import { callCli } from './call-cli.js'
import { DevServer, startDevServer } from './dev-server.js'
import { MockApi, Route, getCLIOptions, startMockApi } from './mock-api-vitest.js'
import { SiteBuilder } from './site-builder.js'
import { temporaryDirectory } from '../../../src/utils/temporary-file.js'

const FIXTURES_DIRECTORY = fileURLToPath(new URL('../__fixtures__/', import.meta.url))

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/utils/mock-execa.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { rm, writeFile } from 'fs/promises'
import { pathToFileURL } from 'url'
import { temporaryFile } from '../../../src/utils/temporary-file.js'

// Saves to disk a JavaScript file with the contents provided and returns
// an environment variable that replaces the `execa` module implementation.
// A cleanup method is also returned, allowing the consumer to remove the
// mock file.
export const createMock = async (contents: string) => {
const { temporaryFile } = await import('tempy')
const path = temporaryFile({ extension: 'js' })

await writeFile(path, contents)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/utils/deploy/hash-fns.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import path from 'node:path'

import { temporaryDirectory } from 'tempy'
import { expect, test } from 'vitest'

import BaseCommand from '../../../../src/commands/base-command.js'
import { DEFAULT_CONCURRENT_HASH } from '../../../../src/utils/deploy/constants.js'
import hashFns from '../../../../src/utils/deploy/hash-fns.js'
import { withSiteBuilder } from '../../../integration/utils/site-builder.js'
import { temporaryDirectory } from '../../../../src/utils/temporary-file.js'

test('Hashes files in a folder', async (t) => {
await withSiteBuilder(t, async (builder) => {
Expand Down
Loading