@pantoken/scaffold 1.1.0 → 1.2.1

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
@@ -63,15 +63,22 @@ await scaffoldProject("react", "./my-app");
63
63
  | `-d, --dir <path>` | Target directory (prompted interactively if omitted on a TTY) |
64
64
  | `-y, --yes` | Never prompt; error instead of prompting for a missing platform/directory |
65
65
  | `--no-install` | Skip automatically installing dependencies after scaffolding |
66
- | `-l, --lang <tag>` | Override the auto-detected display language (e.g. `"hu"`) |
66
+ | `-l, --lang <tag>` | Language for the CLI and the scaffolded project (e.g. `"hu"`) |
67
67
  | `--theme <name>` | Token theme: `rebrand` (default), `canvas`, `canvasHighContrast` |
68
68
  | `--theme-mode <mode>` | Rebrand token mode: `light` (default) or `adaptive` |
69
69
  | `-v, --version` | Print the installed version |
70
70
  | `-h, --help` | Print usage |
71
71
  | `completion <shell>` | Generate a bash/zsh/fish/PowerShell completion script |
72
72
 
73
- The CLI auto-detects its display language from `--lang` > `LC_ALL`/`LANG` > the runtime's `Intl`
74
- 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.
75
82
 
76
83
  ## Architecture
77
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 resolveScaffoldPlatform, c as ThemeVariant, i as isScaffoldPlatform, n as ScaffoldPackageManager, o as scaffoldProject, s as ThemeMode, t as SCAFFOLD_PLATFORMS } from "./index-BloHpRKt.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,15 @@ 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;
119
+ packageManager?: ScaffoldPackageManager;
109
120
  }): Promise<string[]>;
110
121
  /** Package managers `detectPackageManager` can identify. */
111
122
  export type PackageManager = "npm" | "pnpm" | "yarn" | "bun" | "deno" | "vp";
@@ -120,6 +131,13 @@ export type PackageManager = "npm" | "pnpm" | "yarn" | "bun" | "deno" | "vp";
120
131
  * @returns Detected package manager, or undefined
121
132
  */
122
133
  export declare function detectPackageManager(env?: NodeJS.ProcessEnv, execPath?: string): PackageManager | undefined;
134
+ /**
135
+ * The invocation string `create-pantoken-app`'s bin shim shows in `--help`/usage, matching
136
+ * whichever package manager actually invoked it (falls back to the npm form when undetected).
137
+ *
138
+ * @param pm - The detected package manager (defaults to `detectPackageManager()`'s result)
139
+ */
140
+ export declare function buildCreateUsageCommand(pm?: PackageManager): string;
123
141
  /**
124
142
  * Runs the detected package manager's install command in `dir`, wrapped in a clack spinner.
125
143
  * Failures are reported but non-fatal — the project is still usable, just not installed — so the
@@ -139,7 +157,8 @@ export declare function installWithSpinner(dir: string, pm: PackageManager | und
139
157
  * needed — regardless of platform. Otherwise, when `platform` has a `scaffold.json`-derived entry in
140
158
  * `SCAFFOLD_METADATA`, next steps/notes/caveats are rendered from its (localized, `{{var}}`-
141
159
  * substituted) authored strings; failing that, a generic cd/install/run-script fallback is used,
142
- * with the run script itself detected from the scaffolded `package.json` (`dev`, else `preview`).
160
+ * with the run script itself detected from the scaffolded `package.json` (`dev`, else `preview`)
161
+ * or defaulted to `dev` for scaffolded app templates.
143
162
  *
144
163
  * @param dir - The scaffold directory
145
164
  * @param written - The paths written by scaffoldProject