create-jst 0.4.9 → 0.4.11

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.9",
3
+ "version": "0.4.11",
4
4
  "description": "Create a web application from the JST template.",
5
5
  "type": "module",
6
6
  "packageManager": "npm@11.6.2",
@@ -12,7 +12,7 @@
12
12
  "src"
13
13
  ],
14
14
  "engines": {
15
- "node": ">=24.15.0 <25"
15
+ "node": ">=22.14.0"
16
16
  },
17
17
  "scripts": {
18
18
  "lint": "eslint . --max-warnings 0",
@@ -34,6 +34,8 @@
34
34
  "license": "MIT",
35
35
  "dependencies": {
36
36
  "@clack/prompts": "^1.8.1",
37
+ "@reatom/core": "^1001.3.0",
38
+ "@reatom/react": "^1001.0.1",
37
39
  "degit": "^3.10.0"
38
40
  },
39
41
  "devDependencies": {
@@ -29,11 +29,21 @@ export function createProjectInitializer({ onProgress = () => undefined, project
29
29
  onProgress({ type: 'git.initialization.started', specification })
30
30
  await projectGateway.initializeGit(temporaryDestination)
31
31
  }
32
+ else {
33
+ await projectGateway.removeGitMetadata(temporaryDestination)
34
+ }
35
+ if (specification.install) {
36
+ await projectGateway.assertRuntimeSupported(temporaryDestination)
37
+ }
32
38
  await projectGateway.commitDestination(temporaryDestination, specification.destination)
33
39
  rollbackDestination = specification.destination
34
40
  if (specification.install) {
35
41
  onProgress({ type: 'dependencies.installation.started', specification })
36
- await projectGateway.installDependencies(specification.destination, specification.packageManager)
42
+ await projectGateway.installDependencies(
43
+ specification.destination,
44
+ specification.packageManager,
45
+ { gitHooks: specification.initGit },
46
+ )
37
47
  }
38
48
 
39
49
  onProgress({ type: 'project.initialized', specification })
@@ -3,7 +3,7 @@ export const PRIMARY_COLORS = ['dark', 'gray', 'red', 'pink', 'grape', 'violet',
3
3
  export const PACKAGE_MANAGERS = ['npm', 'pnpm']
4
4
  export const STYLE_LANGUAGES = ['css', 'scss']
5
5
  export const EXAMPLES = ['clean', 'showcase']
6
- export const TEMPLATE_SOURCE = 'jst-stack/jst#v0.4.3'
6
+ export const TEMPLATE_SOURCE = 'jst-stack/jst#v0.4.6'
7
7
  export const SHOWCASE_SOURCE = 'jst-stack/jst-showcase#62bc760f9df49fe110c055b914b087ba0d95402a'
8
8
 
9
9
  export function buildProjectSpecification(input) {
@@ -16,6 +16,7 @@ const textExtensions = new Set(['.md', '.mjs', '.yaml', '.yml'])
16
16
  export function createNodeProjectGateway({ nodeExecutable, signal }) {
17
17
  return {
18
18
  assertDestinationIsEmpty,
19
+ assertRuntimeSupported,
19
20
  cleanupDestination,
20
21
  commitDestination,
21
22
  configureExample,
@@ -24,6 +25,7 @@ export function createNodeProjectGateway({ nodeExecutable, signal }) {
24
25
  initializeGit,
25
26
  installDependencies,
26
27
  prepareDestination,
28
+ removeGitMetadata,
27
29
  validateTemplate,
28
30
  }
29
31
 
@@ -53,6 +55,7 @@ export function createNodeProjectGateway({ nodeExecutable, signal }) {
53
55
  return run(nodeExecutable, [
54
56
  'scripts/setup-template.mjs',
55
57
  '--yes',
58
+ '--quiet',
56
59
  '--name', specification.name,
57
60
  '--title', specification.title,
58
61
  '--description', specification.description,
@@ -63,19 +66,13 @@ export function createNodeProjectGateway({ nodeExecutable, signal }) {
63
66
  ], specification.destination, { signal })
64
67
  }
65
68
 
66
- async function configureExample(specification) {
67
- const manifestPath = join(specification.destination, 'package.json')
68
- const manifest = JSON.parse(await readFile(manifestPath, 'utf8'))
69
- manifest.name = specification.name
70
- await writeFile(manifestPath, `${JSON.stringify(manifest, null, '\t')}\n`)
71
- }
72
-
73
69
  function initializeGit(destination) {
74
70
  return run('git', ['init', '--initial-branch=main'], destination, { signal })
75
71
  }
76
72
 
77
- function installDependencies(destination, packageManager) {
73
+ function installDependencies(destination, packageManager, { gitHooks = true } = {}) {
78
74
  return run(packageManager, installCommands[packageManager], destination, {
75
+ env: gitHooks ? undefined : { ...process.env, HUSKY: '0' },
79
76
  shell: process.platform === 'win32',
80
77
  signal,
81
78
  })
@@ -99,6 +96,42 @@ export function createNodeProjectGateway({ nodeExecutable, signal }) {
99
96
  }
100
97
  }
101
98
 
99
+ async function configureExample(specification) {
100
+ const manifestPath = join(specification.destination, 'package.json')
101
+ const manifest = JSON.parse(await readFile(manifestPath, 'utf8'))
102
+ manifest.name = specification.name
103
+ await writeFile(manifestPath, `${JSON.stringify(manifest, null, '\t')}\n`)
104
+ }
105
+
106
+ function removeGitMetadata(destination) {
107
+ return rm(join(destination, '.git'), { force: true, recursive: true })
108
+ }
109
+
110
+ async function assertRuntimeSupported(destination) {
111
+ const manifest = JSON.parse(await readFile(join(destination, 'package.json'), 'utf8'))
112
+ const required = manifest.engines?.node
113
+ const match = /^>=(\d+)\.(\d+)\.(\d+) <(\d+)$/u.exec(required ?? '')
114
+ if (!match) {
115
+ return
116
+ }
117
+ const current = process.versions.node.split('.').map(Number)
118
+ const minimum = match.slice(1, 4).map(Number)
119
+ const maximumMajor = Number(match[4])
120
+ if (current[0] < maximumMajor && compareVersions(current, minimum) >= 0) {
121
+ return
122
+ }
123
+ throw new Error(`This template requires Node.js ${required}; detected ${process.versions.node}. Upgrade Node and run create-jst again.`)
124
+ }
125
+
126
+ function compareVersions(left, right) {
127
+ for (let index = 0; index < right.length; index += 1) {
128
+ if (left[index] !== right[index]) {
129
+ return left[index] - right[index]
130
+ }
131
+ }
132
+ return 0
133
+ }
134
+
102
135
  async function configurePackageManager(destination, packageManager, signal) {
103
136
  const manifestPath = join(destination, 'package.json')
104
137
  const manifest = JSON.parse(await readFile(manifestPath, 'utf8'))
@@ -195,9 +228,9 @@ async function prepareDestination(destination) {
195
228
  return temporaryDestination
196
229
  }
197
230
 
198
- function run(command, args, cwd, { shell = false, signal } = {}) {
231
+ function run(command, args, cwd, { env, shell = false, signal } = {}) {
199
232
  return new Promise((resolve, reject) => {
200
- const child = spawn(command, args, { cwd, shell, signal, stdio: 'inherit' })
233
+ const child = spawn(command, args, { cwd, env, shell, signal, stdio: 'inherit' })
201
234
  child.once('error', error => reject(new Error(`Could not run ${command}: ${error.message}`)))
202
235
  child.once('close', code => {
203
236
  if (code === 0) {
@@ -89,6 +89,11 @@ Usage:
89
89
  The interactive wizard only asks about decisions that affect the generated project.
90
90
  Application title and description are derived from the directory; pass flags only when automation needs overrides.
91
91
 
92
+ Examples:
93
+ npm create jst@latest my-app
94
+ npm create jst@latest my-app -- --yes --style scss
95
+ npm create jst@latest jst-showcase -- --example showcase
96
+
92
97
  Options:
93
98
  --package-manager <manager> auto, npm, or pnpm
94
99
  --no-install create the project without installing dependencies
@@ -74,14 +74,43 @@ export function createReporter(output, environment = {}) {
74
74
  output.write(`${dim(' ◌')} ${message(event.specification)}\n`)
75
75
  },
76
76
  success(specification) {
77
- if (usesClack) {
78
- activeSpinner?.stop('Project created')
79
- prompts.outro(`Ready. Run \`${specification.packageManager} run dev\` in ${basename(specification.destination)}.`)
80
- return
81
- }
82
- output.write(`\n${paint('38;5;114', 'Ready.')} ${specification.title} is in ${paint('38;5;203', basename(specification.destination))}.\n\n`)
83
- output.write(` ${dim('$')} cd ${basename(specification.destination)}\n`)
84
- output.write(` ${dim('$')} ${specification.packageManager} run dev\n\n`)
77
+ renderSuccess({ activeSpinner, dim, output, paint, specification, usesClack })
85
78
  },
86
79
  }
87
80
  }
81
+
82
+ function renderSuccess({ activeSpinner, dim, output, paint, specification, usesClack }) {
83
+ const directory = basename(specification.destination)
84
+ const { guidance, setup } = getNextSteps(specification, directory)
85
+ if (usesClack) {
86
+ activeSpinner?.stop('Project created')
87
+ prompts.note([...setup, '', ...guidance].join('\n'), 'Next steps')
88
+ prompts.outro(`${specification.title} is ready.`)
89
+ return
90
+ }
91
+ output.write(`\n${paint('38;5;114', 'Ready.')} ${specification.title} is in ${paint('38;5;203', directory)}.\n\n`)
92
+ for (const command of setup) {
93
+ output.write(` ${dim('$')} ${command}\n`)
94
+ }
95
+ output.write('\n')
96
+ for (const instruction of guidance) {
97
+ output.write(` ${instruction}\n`)
98
+ }
99
+ output.write('\n')
100
+ }
101
+
102
+ function getNextSteps(specification, directory) {
103
+ const { install, packageManager } = specification
104
+ return {
105
+ guidance: [
106
+ `First slice ${packageManager} run create:slice -- feature firstFeature`,
107
+ `Fast gate ${packageManager} run validate`,
108
+ `Release gate ${packageManager} run check:release`,
109
+ ],
110
+ setup: [
111
+ `cd ${directory}`,
112
+ ...(install ? [] : [`${packageManager} install`]),
113
+ `${packageManager} run dev`,
114
+ ],
115
+ }
116
+ }