create-jst 0.4.9 → 0.4.10

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.10",
4
4
  "description": "Create a web application from the JST template.",
5
5
  "type": "module",
6
6
  "packageManager": "npm@11.6.2",
@@ -33,7 +33,11 @@ export function createProjectInitializer({ onProgress = () => undefined, project
33
33
  rollbackDestination = specification.destination
34
34
  if (specification.install) {
35
35
  onProgress({ type: 'dependencies.installation.started', specification })
36
- await projectGateway.installDependencies(specification.destination, specification.packageManager)
36
+ await projectGateway.installDependencies(
37
+ specification.destination,
38
+ specification.packageManager,
39
+ { gitHooks: specification.initGit },
40
+ )
37
41
  }
38
42
 
39
43
  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.5'
7
7
  export const SHOWCASE_SOURCE = 'jst-stack/jst-showcase#62bc760f9df49fe110c055b914b087ba0d95402a'
8
8
 
9
9
  export function buildProjectSpecification(input) {
@@ -53,6 +53,7 @@ export function createNodeProjectGateway({ nodeExecutable, signal }) {
53
53
  return run(nodeExecutable, [
54
54
  'scripts/setup-template.mjs',
55
55
  '--yes',
56
+ '--quiet',
56
57
  '--name', specification.name,
57
58
  '--title', specification.title,
58
59
  '--description', specification.description,
@@ -74,8 +75,9 @@ export function createNodeProjectGateway({ nodeExecutable, signal }) {
74
75
  return run('git', ['init', '--initial-branch=main'], destination, { signal })
75
76
  }
76
77
 
77
- function installDependencies(destination, packageManager) {
78
+ function installDependencies(destination, packageManager, { gitHooks = true } = {}) {
78
79
  return run(packageManager, installCommands[packageManager], destination, {
80
+ env: gitHooks ? undefined : { ...process.env, HUSKY: '0' },
79
81
  shell: process.platform === 'win32',
80
82
  signal,
81
83
  })
@@ -195,9 +197,9 @@ async function prepareDestination(destination) {
195
197
  return temporaryDestination
196
198
  }
197
199
 
198
- function run(command, args, cwd, { shell = false, signal } = {}) {
200
+ function run(command, args, cwd, { env, shell = false, signal } = {}) {
199
201
  return new Promise((resolve, reject) => {
200
- const child = spawn(command, args, { cwd, shell, signal, stdio: 'inherit' })
202
+ const child = spawn(command, args, { cwd, env, shell, signal, stdio: 'inherit' })
201
203
  child.once('error', error => reject(new Error(`Could not run ${command}: ${error.message}`)))
202
204
  child.once('close', code => {
203
205
  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
+ `Full gate ${packageManager} run check`,
109
+ ],
110
+ setup: [
111
+ `cd ${directory}`,
112
+ ...(install ? [] : [`${packageManager} install`]),
113
+ `${packageManager} run dev`,
114
+ ],
115
+ }
116
+ }