Skip to content

Commit fd28f48

Browse files
fix(deps): remove tempy (#7223)
* fix(deps): remove tempy * fix: lint errors * fix: fmt * fix: remove unecessary code for handling `name` --------- Co-authored-by: Philippe Serhal <[email protected]>
1 parent 4938182 commit fd28f48

File tree

11 files changed

+30
-120
lines changed

11 files changed

+30
-120
lines changed

package-lock.json

Lines changed: 3 additions & 110 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@
142142
"readdirp": "4.1.2",
143143
"semver": "7.7.1",
144144
"source-map-support": "0.5.21",
145-
"tempy": "3.1.0",
146145
"terminal-link": "4.0.0",
147146
"toml": "3.0.0",
148147
"tomlify-j0.4": "3.0.0",

src/lib/functions/runtimes/go/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { dirname, extname } from 'path'
22
import { platform } from 'process'
33

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

76
import type {
87
BaseBuildResult,
@@ -13,6 +12,7 @@ import type {
1312
} from '../index.js'
1413
import execa from '../../../../utils/execa.js'
1514
import { runFunctionsProxy } from '../../local-proxy.js'
15+
import { temporaryFile } from '../../../../utils/temporary-file.js'
1616

1717
const isWindows = platform === 'win32'
1818

src/utils/deploy/deploy-site.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { rm } from 'fs/promises'
22

33
import cleanDeep from 'clean-deep'
4-
import { temporaryDirectory } from 'tempy'
54

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

2525
export type { DeployEvent }
2626

src/utils/temporary-file.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as path from 'node:path'
2+
import * as os from 'node:os'
3+
import * as crypto from 'node:crypto'
4+
import * as fs from 'node:fs'
5+
6+
const uniqueString = () => crypto.randomBytes(8).toString('hex')
7+
8+
const tempDir = os.tmpdir()
9+
10+
export function temporaryFile({ extension }: { extension?: string } = {}): string {
11+
const baseName = uniqueString()
12+
const ext = extension ? '.' + extension.replace(/^\./, '') : ''
13+
return path.join(tempDir, baseName + ext)
14+
}
15+
16+
export function temporaryDirectory({ prefix = '' } = {}): string {
17+
const directory = fs.mkdtempSync(`${tempDir}${path.sep}${prefix}`)
18+
return directory
19+
}

tests/integration/commands/blobs/blobs.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import { env } from 'process'
55
import { ListResultBlob } from '@netlify/blobs'
66
import { BlobsServer } from '@netlify/blobs/server'
77
import httpProxy from 'http-proxy'
8-
import { temporaryDirectory } from 'tempy'
98
import { afterAll, beforeAll, describe, expect, test } from 'vitest'
109

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

1414
const blobsProxy = httpProxy.createProxyServer({})
1515

tests/integration/commands/completion/completion-install.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { describe, test, beforeAll, afterAll } from 'vitest'
22
import fs from 'fs'
33
import { rm } from 'fs/promises'
4-
import { temporaryDirectory } from 'tempy'
54
import { handleQuestions, CONFIRM, DOWN, NO, answerWithValue } from '../../utils/handle-questions.js'
65
import execa from 'execa'
76
import { cliPath } from '../../utils/cli-path.js'
87
import { join } from 'path'
98
import { TABTAB_CONFIG_LINE, AUTOLOAD_COMPINIT } from '../../../../src/utils/command-helpers.js'
9+
import { temporaryDirectory } from '../../../../src/utils/temporary-file.js'
1010

1111
describe('completion:install command', () => {
1212
let tempDir: string

tests/integration/commands/dev/dev-forms-and-redirects.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { describe, test } from 'vitest'
1111

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

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

430-
const { temporaryDirectory } = await import('tempy')
431431
const pluginDirectory = temporaryDirectory()
432432

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

489-
const { temporaryDirectory } = await import('tempy')
490489
const pluginDirectory = temporaryDirectory()
491490

492491
await fs.writeFile(path.join(pluginDirectory, 'manifest.yml'), pluginManifest)

tests/integration/utils/fixture.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { join } from 'path'
33
import { fileURLToPath } from 'url'
44

55
import type { NodeOptions } from 'execa'
6-
import { temporaryDirectory } from 'tempy'
76
import { afterAll, afterEach, beforeAll, beforeEach, describe } from 'vitest'
87

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

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

tests/integration/utils/mock-execa.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { rm, writeFile } from 'fs/promises'
22
import { pathToFileURL } from 'url'
3+
import { temporaryFile } from '../../../src/utils/temporary-file.js'
34

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

1212
await writeFile(path, contents)

tests/unit/utils/deploy/hash-fns.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import path from 'node:path'
22

3-
import { temporaryDirectory } from 'tempy'
43
import { expect, test } from 'vitest'
54

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

1111
test('Hashes files in a folder', async (t) => {
1212
await withSiteBuilder(t, async (builder) => {

0 commit comments

Comments
 (0)