@inglorious/create-app 1.2.0 → 1.3.0

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/README.md CHANGED
@@ -36,10 +36,16 @@ For the JavaScript and TypeScript Vite templates, the CLI then asks about the ap
36
36
  | Translate the app? | `--i18n` / `--no-i18n`, `--languages=en,it` | `@inglorious/i18n`, a catalogue per language and a language picker; the first language is the default |
37
37
  | Enable PWA support? | `--pwa` / `--no-pwa` | `vite-plugin-pwa`, a manifest, icons and service worker registration |
38
38
 
39
- The app is generated in the syntax you chose: lit-html, JSX or Vue. Every question answered by a flag is skipped:
39
+ The app is generated in the syntax you chose: lit-html, JSX or Vue. Every question answered on the command line is skipped, so a project can be created without any prompt:
40
+
41
+ | Question | Argument or flag |
42
+ | --------------------------- | -------------------------------------------- |
43
+ | What is your project named? | The first argument, such as `my-app` |
44
+ | Select a template | `--template=minimal\|js\|ts\|ssx-js\|ssx-ts` |
45
+ | Select a rendering syntax | `--syntax=lit-html\|jsx\|vue` |
40
46
 
41
47
  ```bash
42
- npm create @inglorious/app@latest -- --ui --theme=material --routing --transitions --icons=material --languages=en,it --mobile
48
+ npm create @inglorious/app@latest -- my-app --template=ts --syntax=jsx --ui --theme=material --routing --transitions --icons=material --languages=en,it --no-mobile --no-pwa
43
49
  ```
44
50
 
45
51
  ## Templates
package/bin/index.js CHANGED
@@ -16,6 +16,7 @@ import {
16
16
  USER_ARG_START_INDEX,
17
17
  VITE_APP_TEMPLATES,
18
18
  } from "./lib/constants.js"
19
+ import { SYNTAXES, TEMPLATES } from "./lib/features.js"
19
20
  import { copyDir } from "./lib/file.js"
20
21
  import { addMobileSupport } from "./lib/mobile.js"
21
22
  import { addPwaSupport } from "./lib/pwa.js"
@@ -25,6 +26,8 @@ async function main() {
25
26
  const __dirname = path.dirname(fileURLToPath(import.meta.url))
26
27
  const templatesRoot = path.join(__dirname, "../templates")
27
28
  const cliOptions = parseCliOptions(process.argv.slice(USER_ARG_START_INDEX))
29
+ validateChoice("template", cliOptions.template, TEMPLATES)
30
+ validateChoice("syntax", cliOptions.syntax, SYNTAXES)
28
31
 
29
32
  let canceled = false
30
33
 
@@ -33,45 +36,19 @@ async function main() {
33
36
  return false
34
37
  }
35
38
 
36
- const { projectName, baseTemplate } = await prompts(
39
+ const answers = await prompts(
37
40
  [
38
41
  {
39
- type: "text",
42
+ type: cliOptions.projectName ? null : "text",
40
43
  name: "projectName",
41
44
  message: "What is your project named?",
42
45
  initial: "my-app",
43
46
  },
44
47
  {
45
- type: "select",
48
+ type: cliOptions.template ? null : "select",
46
49
  name: "baseTemplate",
47
50
  message: "Select a template",
48
- choices: [
49
- {
50
- title: "Minimal",
51
- description: "A single HTML file for a zero-build setup",
52
- value: "minimal",
53
- },
54
- {
55
- title: "JavaScript",
56
- description: "A vanilla JavaScript setup with Vite",
57
- value: "js",
58
- },
59
- {
60
- title: "TypeScript",
61
- description: "A TypeScript setup with Vite",
62
- value: "ts",
63
- },
64
- {
65
- title: "SSX (JavaScript)",
66
- description: "Static Site Xecution with JavaScript",
67
- value: "ssx-js",
68
- },
69
- {
70
- title: "SSX (TypeScript)",
71
- description: "Static Site Xecution with TypeScript",
72
- value: "ssx-ts",
73
- },
74
- ],
51
+ choices: toChoices(TEMPLATES),
75
52
  },
76
53
  ],
77
54
  { onCancel },
@@ -82,31 +59,18 @@ async function main() {
82
59
  return
83
60
  }
84
61
 
62
+ const projectName = cliOptions.projectName ?? answers.projectName
63
+ const baseTemplate = cliOptions.template ?? answers.baseTemplate
64
+
85
65
  let renderer = "lit-html"
86
66
 
87
67
  if (baseTemplate !== "minimal") {
88
68
  const { selectedRenderer } = await prompts(
89
69
  {
90
- type: "select",
70
+ type: cliOptions.syntax ? null : "select",
91
71
  name: "selectedRenderer",
92
72
  message: "Select a rendering syntax",
93
- choices: [
94
- {
95
- title: "lit-html (default)",
96
- description: "Tagged template literals (html`<div>...</div>`)",
97
- value: "lit-html",
98
- },
99
- {
100
- title: "JSX",
101
- description: "JSX/TSX syntax (<div>...</div>)",
102
- value: "jsx",
103
- },
104
- {
105
- title: "Vue",
106
- description: "Vue SFC-style templates",
107
- value: "vue",
108
- },
109
- ],
73
+ choices: toChoices(SYNTAXES),
110
74
  },
111
75
  { onCancel },
112
76
  )
@@ -116,7 +80,9 @@ async function main() {
116
80
  return
117
81
  }
118
82
 
119
- renderer = selectedRenderer
83
+ renderer = cliOptions.syntax ?? selectedRenderer
84
+ } else if (cliOptions.syntax && cliOptions.syntax !== "lit-html") {
85
+ console.warn("The minimal template is only available with lit-html.")
120
86
  }
121
87
 
122
88
  let features = {
@@ -223,6 +189,21 @@ async function main() {
223
189
  }
224
190
  }
225
191
 
192
+ function toChoices(options) {
193
+ return Object.entries(options).map(([value, option]) => ({
194
+ value,
195
+ ...option,
196
+ }))
197
+ }
198
+
199
+ function validateChoice(flag, value, options) {
200
+ if (value !== null && !options[value]) {
201
+ throw new Error(
202
+ `Unknown ${flag} "${value}". Choose one of: ${Object.keys(options).join(", ")}.`,
203
+ )
204
+ }
205
+ }
206
+
226
207
  function getLatestVersion(packageName) {
227
208
  try {
228
209
  const version = execSync(`npm view ${packageName} version`, {
package/bin/lib/cli.js CHANGED
@@ -1,5 +1,8 @@
1
1
  export function parseCliOptions(args) {
2
2
  return {
3
+ projectName: args.find((arg) => !arg.startsWith("-")) ?? null,
4
+ template: readValueFlag(args, "template"),
5
+ syntax: readValueFlag(args, "syntax"),
3
6
  mobile: readBooleanFlag(args, "mobile"),
4
7
  pwa: readBooleanFlag(args, "pwa"),
5
8
  ui: readBooleanFlag(args, "ui"),
@@ -1,7 +1,9 @@
1
1
  export const CAPACITOR_VERSION = "^8.5.3"
2
2
  export const VITE_PLUGIN_PWA_VERSION = "^2.0.0"
3
3
  export const VITE_PWA_ASSETS_GENERATOR_VERSION = "^2.0.0"
4
- export const TYPESCRIPT_VERSION = "^7.0.2"
4
+ // TypeScript 7 has no JavaScript API, which typescript-eslint and the
5
+ // Capacitor CLI import, so `typescript` stays on 6.
6
+ export const TYPESCRIPT_VERSION = "npm:@typescript/typescript6@^6.0.2"
5
7
  export const WORKBOX_WINDOW_VERSION = "^7.4.1"
6
8
 
7
9
  export const INDENTATION = 2
@@ -1,5 +1,34 @@
1
1
  // The choices create-app offers for lit-html apps, and what each one brings.
2
2
 
3
+ export const TEMPLATES = {
4
+ minimal: {
5
+ title: "Minimal",
6
+ description: "A single HTML file for a zero-build setup",
7
+ },
8
+ js: {
9
+ title: "JavaScript",
10
+ description: "A vanilla JavaScript setup with Vite",
11
+ },
12
+ ts: { title: "TypeScript", description: "A TypeScript setup with Vite" },
13
+ "ssx-js": {
14
+ title: "SSX (JavaScript)",
15
+ description: "Static Site Xecution with JavaScript",
16
+ },
17
+ "ssx-ts": {
18
+ title: "SSX (TypeScript)",
19
+ description: "Static Site Xecution with TypeScript",
20
+ },
21
+ }
22
+
23
+ export const SYNTAXES = {
24
+ "lit-html": {
25
+ title: "lit-html (default)",
26
+ description: "Tagged template literals (html`<div>...</div>`)",
27
+ },
28
+ jsx: { title: "JSX", description: "JSX/TSX syntax (<div>...</div>)" },
29
+ vue: { title: "Vue", description: "Vue SFC-style templates" },
30
+ }
31
+
3
32
  export const THEMES = {
4
33
  inglorious: { title: "Inglorious", description: "Neon, videogame-inspired" },
5
34
  material: { title: "Material", description: "Material Design inspired" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/create-app",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "A scaffolding tool to quickly create a new app with Inglorious Web.",
5
5
  "author": "Matteo Antony Mistretta <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
6
6
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  "prompts": "^2.4.2"
38
38
  },
39
39
  "devDependencies": {
40
- "@inglorious/eslint-config": "1.1.2",
40
+ "@inglorious/eslint-config": "1.1.3",
41
41
  "prettier": "^3.9.6"
42
42
  },
43
43
  "scripts": {
@@ -21,13 +21,14 @@
21
21
  "@inglorious/eslint-config": "workspace:*",
22
22
  "@inglorious/vite-plugin-hmr": "workspace:*",
23
23
  "@types/node": "^22.20.5",
24
+ "@typescript/native": "npm:typescript@^7.0.2",
24
25
  "eslint": "^10.13.0",
25
26
  "jiti": "^2.7.0",
26
27
  "prettier": "^3.9.10",
27
28
  "rollup-plugin-minify-template-literals": "^2.2.0",
28
29
  "sharp": "^0.35.5",
29
30
  "svgo": "^4.1.0",
30
- "typescript": "^7.0.2",
31
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
31
32
  "vite": "^8.3.4",
32
33
  "vite-plugin-image-optimizer": "^2.0.3"
33
34
  },
@@ -23,13 +23,14 @@
23
23
  "@inglorious/vite-plugin-hmr": "workspace:*",
24
24
  "@inglorious/vite-plugin-jsx": "workspace:*",
25
25
  "@types/node": "^22.20.5",
26
+ "@typescript/native": "npm:typescript@^7.0.2",
26
27
  "eslint": "^10.13.0",
27
28
  "jiti": "^2.7.0",
28
29
  "prettier": "^3.9.10",
29
30
  "rollup-plugin-minify-template-literals": "^2.2.0",
30
31
  "sharp": "^0.35.5",
31
32
  "svgo": "^4.1.0",
32
- "typescript": "^7.0.2",
33
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
33
34
  "vite": "^8.3.4",
34
35
  "vite-plugin-image-optimizer": "^2.0.3"
35
36
  },
@@ -1,5 +1,4 @@
1
1
  import type { AppApi } from "../types"
2
-
3
2
  import { Message } from "./types/message"
4
3
 
5
4
  export const App = {
@@ -22,13 +22,14 @@
22
22
  "@inglorious/vite-plugin-hmr": "workspace:*",
23
23
  "@inglorious/vite-plugin-vue": "workspace:*",
24
24
  "@types/node": "^22.20.5",
25
+ "@typescript/native": "npm:typescript@^7.0.2",
25
26
  "eslint": "^10.13.0",
26
27
  "jiti": "^2.7.0",
27
28
  "prettier": "^3.9.10",
28
29
  "rollup-plugin-minify-template-literals": "^2.2.0",
29
30
  "sharp": "^0.35.5",
30
31
  "svgo": "^4.1.0",
31
- "typescript": "^7.0.2",
32
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
32
33
  "vite": "^8.3.4",
33
34
  "vite-plugin-image-optimizer": "^2.0.3"
34
35
  },
@@ -4,4 +4,4 @@ import { mount } from "@inglorious/web"
4
4
  import { App } from "./app.vue"
5
5
  import { store } from "./store"
6
6
 
7
- mount(store, (api) => App.render(null, api), document.getElementById("root"))
7
+ mount(store, (api) => App.render(null, api), document.getElementById("root")!)