create-jst 0.4.30 → 0.4.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-jst",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.33",
|
|
4
4
|
"description": "Create a web application from the JST template.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "npm@11.6.2",
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=22.14.0"
|
|
16
16
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
"scripts": {
|
|
18
|
+
"audit:sources": "node scripts/audit-sources.mjs",
|
|
19
|
+
"canary:migrate": "node scripts/migration-canary.mjs",
|
|
20
20
|
"lint": "eslint . --max-warnings 0",
|
|
21
21
|
"benchmark": "node scripts/run-benchmarks.mjs",
|
|
22
22
|
"benchmark:update": "node scripts/run-benchmarks.mjs --write-baseline",
|
|
23
|
-
|
|
23
|
+
"test": "node --test test/degitTemplateGateway.test.mjs test/integration.test.mjs test/migration.test.mjs test/nodeMigrationGateway.test.mjs test/nodeProjectGateway.test.mjs test/options.test.mjs test/projectInitializer.test.mjs",
|
|
24
24
|
"test:generated": "node --test test/generatedProject.test.mjs",
|
|
25
25
|
"check": "npm run lint && npm test && npm pack --dry-run",
|
|
26
26
|
"prepublishOnly": "npm run check"
|
|
@@ -18,7 +18,7 @@ export const PRIMARY_COLORS = [
|
|
|
18
18
|
export const PACKAGE_MANAGERS = ['npm', 'pnpm']
|
|
19
19
|
export const STYLE_LANGUAGES = ['css', 'scss']
|
|
20
20
|
export const EXAMPLES = ['clean', 'showcase']
|
|
21
|
-
export const TEMPLATE_SOURCE = 'jst-stack/jst#v0.4.
|
|
21
|
+
export const TEMPLATE_SOURCE = 'jst-stack/jst#v0.4.32'
|
|
22
22
|
export const SHOWCASE_SOURCE = 'jst-stack/jst-showcase#da0fbe07b2a2d529dce7a0178ea756caa87238f4'
|
|
23
23
|
|
|
24
24
|
export function buildProjectSpecification(input) {
|
|
@@ -1,14 +1,57 @@
|
|
|
1
1
|
import degit from 'degit'
|
|
2
|
-
import {
|
|
2
|
+
import { execFile } from 'node:child_process'
|
|
3
|
+
import { cp, mkdir, rm } from 'node:fs/promises'
|
|
3
4
|
import { isAbsolute, resolve } from 'node:path'
|
|
5
|
+
import { promisify } from 'node:util'
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
const execute = promisify(execFile)
|
|
8
|
+
const COMMIT_REFERENCE = /^[\da-f]{40}$/u
|
|
9
|
+
|
|
10
|
+
export function createDegitTemplateGateway({
|
|
11
|
+
gitExecutable = 'git',
|
|
12
|
+
gitTimeout = 180_000,
|
|
13
|
+
resolveRemote = (repository) => `https://github.com/${repository}.git`,
|
|
14
|
+
} = {}) {
|
|
6
15
|
return {
|
|
7
|
-
clone(source, destination) {
|
|
16
|
+
async clone(source, destination) {
|
|
8
17
|
if (isAbsolute(source) || source.startsWith('.')) {
|
|
9
18
|
return cp(resolve(source), destination, { recursive: true })
|
|
10
19
|
}
|
|
20
|
+
|
|
21
|
+
const [repository, reference] = splitSource(source)
|
|
22
|
+
if (COMMIT_REFERENCE.test(reference)) {
|
|
23
|
+
return cloneCommit({ destination, gitExecutable, gitTimeout, reference, remote: resolveRemote(repository), repository })
|
|
24
|
+
}
|
|
25
|
+
|
|
11
26
|
return degit(source, { disableCache: true, force: false, verbose: false }).clone(destination)
|
|
12
27
|
},
|
|
13
28
|
}
|
|
14
29
|
}
|
|
30
|
+
|
|
31
|
+
function splitSource(source) {
|
|
32
|
+
const [repository, reference = ''] = source.split('#')
|
|
33
|
+
return [repository, reference]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function cloneCommit({ destination, gitExecutable, gitTimeout, reference, remote, repository }) {
|
|
37
|
+
await mkdir(destination, { recursive: true })
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
await git(gitExecutable, ['init', '--quiet'], destination, gitTimeout)
|
|
41
|
+
await git(gitExecutable, ['fetch', '--quiet', '--depth=1', remote, reference], destination, gitTimeout)
|
|
42
|
+
await git(gitExecutable, ['checkout', '--quiet', '--detach', 'FETCH_HEAD'], destination, gitTimeout)
|
|
43
|
+
} catch (error) {
|
|
44
|
+
throw new Error(`Could not download ${repository}#${reference}: ${describeFailure(error)}`, { cause: error })
|
|
45
|
+
} finally {
|
|
46
|
+
await rm(resolve(destination, '.git'), { force: true, recursive: true })
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function git(executable, args, cwd, timeout) {
|
|
51
|
+
return execute(executable, args, { cwd, maxBuffer: 8 * 1024 * 1024, timeout })
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function describeFailure(error) {
|
|
55
|
+
const stderr = error?.stderr?.trim()
|
|
56
|
+
return stderr ? stderr.split('\n').at(-1) : (error?.message ?? String(error))
|
|
57
|
+
}
|