@pantoken/scaffold 1.0.1 → 1.2.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
@@ -29,8 +29,9 @@ npx @pantoken/scaffold --lang hu
29
29
  ```
30
30
 
31
31
  `npx` works regardless of which package manager you use. Substitute `pnpm dlx`, `yarn dlx`,
32
- `bunx`, or `deno run npm:` for `npx` if you prefer — the printed "Next steps" install command
33
- matches whichever one invoked the CLI (detected from `npm_config_user_agent`).
32
+ `bunx`, or `deno run npm:` for `npx` if you prefer — dependencies are installed automatically with
33
+ whichever one invoked the CLI (detected from `npm_config_user_agent`), leaving "start the dev
34
+ server" as the only manual step. Pass `--no-install` to skip the automatic install.
34
35
 
35
36
  Run `npx @pantoken/scaffold --help` for the full flag reference, or `npx @pantoken/scaffold
36
37
  completion <shell>` to generate a bash/zsh/fish/PowerShell completion script.
@@ -61,15 +62,23 @@ await scaffoldProject("react", "./my-app");
61
62
  | `[platform]` | Platform to scaffold (prompted interactively if omitted on a TTY) |
62
63
  | `-d, --dir <path>` | Target directory (prompted interactively if omitted on a TTY) |
63
64
  | `-y, --yes` | Never prompt; error instead of prompting for a missing platform/directory |
64
- | `-l, --lang <tag>` | Override the auto-detected display language (e.g. `"hu"`) |
65
+ | `--no-install` | Skip automatically installing dependencies after scaffolding |
66
+ | `-l, --lang <tag>` | Language for the CLI and the scaffolded project (e.g. `"hu"`) |
65
67
  | `--theme <name>` | Token theme: `rebrand` (default), `canvas`, `canvasHighContrast` |
66
68
  | `--theme-mode <mode>` | Rebrand token mode: `light` (default) or `adaptive` |
67
69
  | `-v, --version` | Print the installed version |
68
70
  | `-h, --help` | Print usage |
69
71
  | `completion <shell>` | Generate a bash/zsh/fish/PowerShell completion script |
70
72
 
71
- The CLI auto-detects its display language from `--lang` > `LC_ALL`/`LANG` > the runtime's `Intl`
72
- locale > English, falling back to English for any untranslated string.
73
+ The CLI auto-detects its language from `--lang` > `LC_ALL`/`LANG` > the runtime's `Intl` locale >
74
+ English, falling back to English for any untranslated string. Region subtags survive when pantoken
75
+ supports them (`pt_BR.UTF-8` resolves to `pt-BR`) and narrow to the base language when it doesn't
76
+ (`es_MX` resolves to `es`).
77
+
78
+ The resolved locale also shapes the generated project: entry markup gets a matching `lang`/`dir`
79
+ pair (so `--lang ar` scaffolds `<html lang="ar" dir="rtl">`), and the project README is written in
80
+ that language where a translation exists. An explicit `--lang` must name a supported locale — it
81
+ errors rather than silently falling back, since the value is written into the scaffolded files.
73
82
 
74
83
  ## Architecture
75
84
 
package/dist/cli.d.mts CHANGED
@@ -1,21 +1,30 @@
1
- import { a as scaffoldProject, i as resolveScaffoldPlatform, o as ThemeMode, r as isScaffoldPlatform, s as ThemeVariant, t as SCAFFOLD_PLATFORMS } from "./index-CyolWk0E.mjs";
1
+ import { a as scaffoldProject, i as resolveScaffoldPlatform, o as ThemeMode, r as isScaffoldPlatform, s as ThemeVariant, t as SCAFFOLD_PLATFORMS } from "./index-D2-Dhvt8.mjs";
2
2
  import { Command } from "commander";
3
3
  //#region src/locale.d.ts
4
- /**
5
- * Locale detection and message lookup for the scaffold CLI.
6
- *
7
- * @module
8
- * @alpha
9
- */
4
+ /** Every locale tag pantoken supports, as `--lang` accepts them. */
5
+ export declare const SUPPORTED_LOCALES: readonly string[];
10
6
  /** Resolved locale plus a message lookup function. */
11
7
  interface LocaleLookup {
12
8
  readonly locale: string;
13
9
  /** Looks up `key`, substituting any `{{param}}` placeholders from `params`. */
14
10
  t: (key: string, params?: Record<string, string>) => string;
15
11
  }
12
+ /**
13
+ * Commander option validator for `--lang`.
14
+ *
15
+ * Unlike ambient detection, an explicit flag must not silently fall back to English — and because
16
+ * the resolved tag is written into scaffolded files (an HTML `lang`/`dir` attribute), constraining
17
+ * it to the registry also keeps arbitrary caller input out of generated markup.
18
+ *
19
+ * @throws InvalidArgumentError if the value isn't a supported locale
20
+ */
21
+ export declare function validateLocaleTag(value: string): string;
16
22
  /**
17
23
  * Resolves the active locale: --lang flag \> LC_ALL/LANG env \> Intl \> "en".
18
24
  *
25
+ * Ambient sources (env, Intl) are advisory: an unsupported or region-only tag narrows to its
26
+ * closest supported parent (`pt_BR.UTF-8` → `pt-BR`, `es_MX` → `es`) and falls back to `"en"`.
27
+ *
19
28
  * @param options - Detection options. `langFlag` is an optional --lang flag value; `env` is
20
29
  * environment variables (defaults to process.env); `intl` is an optional injected
21
30
  * Intl.DateTimeFormat locale function (for testing).
@@ -99,13 +108,14 @@ export declare function resolveScaffoldTarget(options: ResolveScaffoldTargetOpti
99
108
  * @param platform - The scaffold platform
100
109
  * @param dir - The target directory
101
110
  * @param t - Localized string lookup
102
- * @param options - `theme`/`mode`/`cdn` forwarded to {@link scaffoldProject}
111
+ * @param options - `theme`/`mode`/`cdn`/`locale` forwarded to {@link scaffoldProject}
103
112
  * @returns The paths written by scaffoldProject
104
113
  */
105
114
  export declare function scaffoldWithSpinner(platform: string, dir: string, t: LocaleLookup["t"], options?: {
106
115
  theme?: ThemeVariant;
107
116
  mode?: ThemeMode;
108
117
  cdn?: string;
118
+ locale?: string;
109
119
  }): Promise<string[]>;
110
120
  /** Package managers `detectPackageManager` can identify. */
111
121
  export type PackageManager = "npm" | "pnpm" | "yarn" | "bun" | "deno" | "vp";
@@ -120,20 +130,41 @@ export type PackageManager = "npm" | "pnpm" | "yarn" | "bun" | "deno" | "vp";
120
130
  * @returns Detected package manager, or undefined
121
131
  */
122
132
  export declare function detectPackageManager(env?: NodeJS.ProcessEnv, execPath?: string): PackageManager | undefined;
133
+ /**
134
+ * The invocation string `create-pantoken-app`'s bin shim shows in `--help`/usage, matching
135
+ * whichever package manager actually invoked it (falls back to the npm form when undetected).
136
+ *
137
+ * @param pm - The detected package manager (defaults to `detectPackageManager()`'s result)
138
+ */
139
+ export declare function buildCreateUsageCommand(pm?: PackageManager): string;
140
+ /**
141
+ * Runs the detected package manager's install command in `dir`, wrapped in a clack spinner.
142
+ * Failures are reported but non-fatal — the project is still usable, just not installed — so the
143
+ * caller decides how `printNextSteps` should reflect the outcome via the returned boolean.
144
+ *
145
+ * @param dir - The scaffold directory to install into
146
+ * @param pm - The detected package manager (defaults to npm's command when undefined)
147
+ * @param t - Localized string lookup
148
+ * @returns Whether the install command exited successfully
149
+ */
150
+ export declare function installWithSpinner(dir: string, pm: PackageManager | undefined, t: LocaleLookup["t"]): boolean;
123
151
  /**
124
152
  * Prints the post-scaffold "Next steps" block (plus any template-authored notes/caveats).
125
153
  *
126
- * When `platform` has a `scaffold.json`-derived entry in `SCAFFOLD_METADATA`, next steps/notes/
127
- * caveats are rendered from its (localized, `{{var}}`-substituted) authored strings. Otherwise a
128
- * generic cd/install/run-script fallback is used, with the run script itself detected from the
129
- * scaffolded `package.json` (`dev`, else `preview`).
154
+ * When `installed` is true (dependencies were already installed automatically), the block collapses
155
+ * to the single remaining manual action — starting the dev server, prefixed with `cd <dir>` when
156
+ * needed — regardless of platform. Otherwise, when `platform` has a `scaffold.json`-derived entry in
157
+ * `SCAFFOLD_METADATA`, next steps/notes/caveats are rendered from its (localized, `{{var}}`-
158
+ * substituted) authored strings; failing that, a generic cd/install/run-script fallback is used,
159
+ * with the run script itself detected from the scaffolded `package.json` (`dev`, else `preview`).
130
160
  *
131
161
  * @param dir - The scaffold directory
132
162
  * @param written - The paths written by scaffoldProject
133
163
  * @param t - Localized string lookup
134
164
  * @param platform - The resolved (alias-free) scaffold platform, used to look up `scaffold.json` metadata
165
+ * @param installed - Whether dependencies were already installed automatically
135
166
  */
136
- export declare function printNextSteps(dir: string, written: string[], t: LocaleLookup["t"], platform?: string): void;
167
+ export declare function printNextSteps(dir: string, written: string[], t: LocaleLookup["t"], platform?: string, installed?: boolean): void;
137
168
  /**
138
169
  * Shared commander Argument validator for the platform positional.
139
170
  * Used by all three CLIs (scaffold, create-pantoken-app, pantoken-ai scaffold)