@format.dev/cli 0.0.0 → 0.1.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.
Files changed (109) hide show
  1. package/README.md +29 -20
  2. package/bin/format.mjs +20 -0
  3. package/dist/config-Dq7O4e8N.mjs +63 -0
  4. package/dist/config.d.mts +21 -0
  5. package/dist/config.mjs +3 -0
  6. package/dist/draw-random-name-BzvSSVqO.d.mts +4 -0
  7. package/dist/draw-random-name-Dpt6YmUk.mjs +13 -0
  8. package/dist/index.d.mts +1 -0
  9. package/dist/index.mjs +1539 -0
  10. package/dist/install-BiDrmMgJ.mjs +1486 -0
  11. package/dist/lockstep.d.mts +27 -0
  12. package/dist/lockstep.mjs +30 -0
  13. package/dist/project-pX62Di_9.mjs +124 -0
  14. package/dist/random-name.d.mts +2 -0
  15. package/dist/random-name.mjs +3 -0
  16. package/dist/scaffold-shared.d.mts +2 -0
  17. package/dist/scaffold-shared.mjs +3 -0
  18. package/dist/scaffold.d.mts +191 -0
  19. package/dist/scaffold.mjs +6 -0
  20. package/dist/shared-BD62UD5L.d.mts +32 -0
  21. package/dist/shared-CM3vyUlL.mjs +143 -0
  22. package/env.d.ts +99 -0
  23. package/package.json +86 -34
  24. package/templates/html/documents/welcome/data/alternative.json +3 -0
  25. package/templates/html/documents/welcome/data/default.json +3 -0
  26. package/templates/html/documents/welcome/index.html +32 -0
  27. package/templates/html/documents/welcome/index.ts +4 -0
  28. package/templates/html/documents/welcome/pages/Close/close.html +9 -0
  29. package/templates/html/documents/welcome/pages/Cover/cover.html +13 -0
  30. package/templates/html/documents/welcome/pages/FeatureShowcase/feature-showcase.css +296 -0
  31. package/templates/html/documents/welcome/pages/FeatureShowcase/feature-showcase.html +296 -0
  32. package/templates/html/documents/welcome/pages/NextSteps/next-steps.css +107 -0
  33. package/templates/html/documents/welcome/pages/NextSteps/next-steps.html +398 -0
  34. package/templates/html/documents/welcome/styles.css +214 -0
  35. package/templates/html/format.config.json +4 -0
  36. package/templates/html/package.json +15 -0
  37. package/templates/html/tsconfig.json +3 -0
  38. package/templates/react/documents/welcome/components/ButtonLink.tsx +29 -0
  39. package/templates/react/documents/welcome/data/alternative.json +3 -0
  40. package/templates/react/documents/welcome/data/default.json +3 -0
  41. package/templates/react/documents/welcome/data/schema.ts +7 -0
  42. package/templates/react/documents/welcome/icons/propeller-asterisk.svg +1 -0
  43. package/templates/react/documents/welcome/index.tsx +59 -0
  44. package/templates/react/documents/welcome/logos/_logo-base.tsx +9 -0
  45. package/templates/react/documents/welcome/logos/aws-lambda.tsx +22 -0
  46. package/templates/react/documents/welcome/logos/bun.tsx +30 -0
  47. package/templates/react/documents/welcome/logos/cloudflare-workers.tsx +52 -0
  48. package/templates/react/documents/welcome/logos/css-modules.tsx +54 -0
  49. package/templates/react/documents/welcome/logos/css-official.tsx +18 -0
  50. package/templates/react/documents/welcome/logos/deno.tsx +17 -0
  51. package/templates/react/documents/welcome/logos/linaria.tsx +18 -0
  52. package/templates/react/documents/welcome/logos/node.tsx +47 -0
  53. package/templates/react/documents/welcome/logos/panda-css.tsx +18 -0
  54. package/templates/react/documents/welcome/logos/sass.tsx +12 -0
  55. package/templates/react/documents/welcome/logos/tailwind.tsx +45 -0
  56. package/templates/react/documents/welcome/logos/vanilla-extract.tsx +74 -0
  57. package/templates/react/documents/welcome/logos/vercel.tsx +17 -0
  58. package/templates/react/documents/welcome/pages/Close/ClosePage.tsx +13 -0
  59. package/templates/react/documents/welcome/pages/Cover/CoverPage.tsx +17 -0
  60. package/templates/react/documents/welcome/pages/FeatureShowcase/FeatureShowcasePage.tsx +221 -0
  61. package/templates/react/documents/welcome/pages/FeatureShowcase/feature-showcase.css +296 -0
  62. package/templates/react/documents/welcome/pages/FeatureShowcase/mountains.ts +27 -0
  63. package/templates/react/documents/welcome/pages/NextSteps/NextStepsPage.tsx +146 -0
  64. package/templates/react/documents/welcome/pages/NextSteps/next-steps.css +107 -0
  65. package/templates/react/documents/welcome/styles.css +214 -0
  66. package/templates/react/documents/welcome/types.ts +4 -0
  67. package/templates/react/format.config.json +4 -0
  68. package/templates/react/package.json +22 -0
  69. package/templates/react/tsconfig.json +6 -0
  70. package/templates/shared/README.md +18 -0
  71. package/templates/shared/_env +1 -0
  72. package/templates/shared/_gitignore +3 -0
  73. package/templates/shared/documents/welcome/assets/deploy.svg +268 -0
  74. package/templates/shared/documents/welcome/assets/logo.svg +22 -0
  75. package/templates/shared/documents/welcome/assets/mona-sans.woff2 +0 -0
  76. package/templates/shared/documents/welcome/assets/styling.svg +59 -0
  77. package/templates/vue/documents/welcome/components/ButtonLink.vue +28 -0
  78. package/templates/vue/documents/welcome/data/alternative.json +3 -0
  79. package/templates/vue/documents/welcome/data/default.json +3 -0
  80. package/templates/vue/documents/welcome/data/schema.ts +7 -0
  81. package/templates/vue/documents/welcome/index.vue +48 -0
  82. package/templates/vue/documents/welcome/logos/aws-lambda.vue +18 -0
  83. package/templates/vue/documents/welcome/logos/bun.vue +26 -0
  84. package/templates/vue/documents/welcome/logos/cloudflare-workers.vue +48 -0
  85. package/templates/vue/documents/welcome/logos/css-modules.vue +49 -0
  86. package/templates/vue/documents/welcome/logos/css-official.vue +14 -0
  87. package/templates/vue/documents/welcome/logos/deno.vue +13 -0
  88. package/templates/vue/documents/welcome/logos/linaria.vue +14 -0
  89. package/templates/vue/documents/welcome/logos/node.vue +43 -0
  90. package/templates/vue/documents/welcome/logos/panda-css.vue +14 -0
  91. package/templates/vue/documents/welcome/logos/sass.vue +8 -0
  92. package/templates/vue/documents/welcome/logos/tailwind.vue +41 -0
  93. package/templates/vue/documents/welcome/logos/vanilla-extract.vue +70 -0
  94. package/templates/vue/documents/welcome/logos/vercel.vue +13 -0
  95. package/templates/vue/documents/welcome/pages/Close/ClosePage.vue +11 -0
  96. package/templates/vue/documents/welcome/pages/Cover/CoverPage.vue +19 -0
  97. package/templates/vue/documents/welcome/pages/FeatureShowcase/FeatureShowcasePage.vue +217 -0
  98. package/templates/vue/documents/welcome/pages/FeatureShowcase/feature-showcase.css +296 -0
  99. package/templates/vue/documents/welcome/pages/FeatureShowcase/mountains.ts +27 -0
  100. package/templates/vue/documents/welcome/pages/NextSteps/NextStepsPage.vue +146 -0
  101. package/templates/vue/documents/welcome/pages/NextSteps/next-steps.css +107 -0
  102. package/templates/vue/documents/welcome/styles.css +214 -0
  103. package/templates/vue/documents/welcome/types.ts +4 -0
  104. package/templates/vue/format.config.json +4 -0
  105. package/templates/vue/package.json +19 -0
  106. package/templates/vue/tsconfig.json +7 -0
  107. package/tsconfig.recommended.json +22 -0
  108. package/index.d.ts +0 -2
  109. package/index.js +0 -3
@@ -0,0 +1,27 @@
1
+ //#region src/versioning/deps.d.ts
2
+ declare const DEPENDENCY_SECTIONS: readonly ["dependencies", "devDependencies", "optionalDependencies"];
3
+ type DependencySection = (typeof DEPENDENCY_SECTIONS)[number];
4
+ interface DependencyMismatch {
5
+ name: string;
6
+ section: DependencySection;
7
+ actual: string;
8
+ expected: string;
9
+ }
10
+ //#endregion
11
+ //#region src/versioning/lockstep.d.ts
12
+ interface LockstepStatus {
13
+ pinnedVersion: string | null;
14
+ mismatches: DependencyMismatch[];
15
+ }
16
+ /**
17
+ * The lockstep check behind `format version`, exposed as a library call so
18
+ * Studio and the compiler validate against the same source of truth —
19
+ * config.version — instead of each reimplementing it.
20
+ *
21
+ * Non-throwing: returns `pinnedVersion: null` when there's no resolvable config,
22
+ * so the caller decides whether that's fatal (Studio boot) or a skipped warning
23
+ * (a compile run outside a project).
24
+ */
25
+ declare function getLockstepStatus(cwd: string): Promise<LockstepStatus>;
26
+ //#endregion
27
+ export { type DependencyMismatch, LockstepStatus, getLockstepStatus };
@@ -0,0 +1,30 @@
1
+ import "./config-Dq7O4e8N.mjs";
2
+ import { t as loadProjectState } from "./project-pX62Di_9.mjs";
3
+
4
+ //#region src/versioning/lockstep.ts
5
+ /**
6
+ * The lockstep check behind `format version`, exposed as a library call so
7
+ * Studio and the compiler validate against the same source of truth —
8
+ * config.version — instead of each reimplementing it.
9
+ *
10
+ * Non-throwing: returns `pinnedVersion: null` when there's no resolvable config,
11
+ * so the caller decides whether that's fatal (Studio boot) or a skipped warning
12
+ * (a compile run outside a project).
13
+ */
14
+ async function getLockstepStatus(cwd) {
15
+ try {
16
+ const state = await loadProjectState(cwd);
17
+ return {
18
+ pinnedVersion: state.pinnedVersion,
19
+ mismatches: state.mismatches
20
+ };
21
+ } catch {
22
+ return {
23
+ pinnedVersion: null,
24
+ mismatches: []
25
+ };
26
+ }
27
+ }
28
+
29
+ //#endregion
30
+ export { getLockstepStatus };
@@ -0,0 +1,124 @@
1
+ import { a as readConfigFile, i as findConfigPath, r as detectIndent, s as CliError } from "./config-Dq7O4e8N.mjs";
2
+ import fs from "node:fs/promises";
3
+ import { existsSync } from "node:fs";
4
+ import { dirname, join } from "node:path";
5
+
6
+ //#region src/versioning/deps.ts
7
+ const DEPENDENCY_SECTIONS = [
8
+ "dependencies",
9
+ "devDependencies",
10
+ "optionalDependencies"
11
+ ];
12
+ function packageJsonPathFor(configPath) {
13
+ const candidate = join(dirname(configPath), "package.json");
14
+ return existsSync(candidate) ? candidate : null;
15
+ }
16
+ async function scanFormatDependencies(packageJsonPath) {
17
+ const raw = await fs.readFile(packageJsonPath, "utf8");
18
+ const packageJson = JSON.parse(raw);
19
+ return DEPENDENCY_SECTIONS.flatMap((section) => {
20
+ const entries = packageJson[section] ?? {};
21
+ return Object.entries(entries).filter(([name]) => name.startsWith("@format.dev/")).map(([name, version]) => ({
22
+ name,
23
+ section,
24
+ version
25
+ }));
26
+ });
27
+ }
28
+ function findMismatches(args) {
29
+ const { pinnedVersion, dependencies } = args;
30
+ return dependencies.filter((dependency) => !dependency.version.startsWith("workspace:")).filter((dependency) => dependency.version !== pinnedVersion).map((dependency) => ({
31
+ name: dependency.name,
32
+ section: dependency.section,
33
+ actual: dependency.version,
34
+ expected: pinnedVersion
35
+ }));
36
+ }
37
+ async function rewriteFormatDependencies(args) {
38
+ const { packageJsonPath, version } = args;
39
+ const raw = await fs.readFile(packageJsonPath, "utf8");
40
+ const packageJson = JSON.parse(raw);
41
+ const rewritten = [];
42
+ for (const section of DEPENDENCY_SECTIONS) {
43
+ const entries = packageJson[section];
44
+ if (!entries) continue;
45
+ for (const [name, currentVersion] of Object.entries(entries)) {
46
+ const isNotFormatPackage = !name.startsWith("@format.dev/");
47
+ const isWorkspaceLink = currentVersion.startsWith("workspace:");
48
+ if (isNotFormatPackage || isWorkspaceLink || currentVersion === version) continue;
49
+ entries[name] = version;
50
+ rewritten.push({
51
+ name,
52
+ from: currentVersion,
53
+ to: version
54
+ });
55
+ }
56
+ }
57
+ if (rewritten.length > 0) {
58
+ const indent = detectIndent(raw);
59
+ await fs.writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, indent)}\n`, "utf8");
60
+ }
61
+ return rewritten;
62
+ }
63
+
64
+ //#endregion
65
+ //#region src/versioning/semver.ts
66
+ const EXACT_SEMVER = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
67
+ function isExactVersion(version) {
68
+ return EXACT_SEMVER.test(version);
69
+ }
70
+ function parseVersion(version) {
71
+ const match = /^(\d+)\.(\d+)\.(\d+)(-[0-9A-Za-z.-]+)?/.exec(version);
72
+ if (!match) return null;
73
+ return {
74
+ major: Number(match[1]),
75
+ minor: Number(match[2]),
76
+ patch: Number(match[3]),
77
+ hasPrerelease: match[4] !== void 0
78
+ };
79
+ }
80
+ function isNewer(candidate, current) {
81
+ const next = parseVersion(candidate);
82
+ const now = parseVersion(current);
83
+ if (!next || !now) return false;
84
+ if (next.major !== now.major) return next.major > now.major;
85
+ if (next.minor !== now.minor) return next.minor > now.minor;
86
+ if (next.patch !== now.patch) return next.patch > now.patch;
87
+ return now.hasPrerelease && !next.hasPrerelease;
88
+ }
89
+ function mayHaveBreakingChanges(from, to) {
90
+ const before = parseVersion(from);
91
+ const after = parseVersion(to);
92
+ if (!before || !after) return false;
93
+ if (after.major > before.major) return true;
94
+ return before.major === 0 && after.minor > before.minor;
95
+ }
96
+
97
+ //#endregion
98
+ //#region src/project.ts
99
+ const NO_CONFIG_MESSAGE = "Could not find a Format config file. It should be named format.config.{json|jsonc} and placed in the root of your repo. Run `npm create format` to start a new project.";
100
+ async function loadProjectState(startDir) {
101
+ const configPath = findConfigPath(startDir, { baseName: process.env.FMT_CONFIG_FILE_NAME });
102
+ if (!configPath) throw new CliError(NO_CONFIG_MESSAGE);
103
+ const configFile = await readConfigFile(configPath);
104
+ const projectDir = dirname(configPath);
105
+ const rawVersion = configFile.config.version;
106
+ const pinnedVersion = typeof rawVersion === "string" ? rawVersion : null;
107
+ if (pinnedVersion && !isExactVersion(pinnedVersion)) throw new CliError(`Invalid "version" in ${configPath}: "${pinnedVersion}". It must be an exact version like "0.1.2" — ranges are not supported.`);
108
+ const packageJsonPath = packageJsonPathFor(configPath);
109
+ const dependencies = packageJsonPath ? await scanFormatDependencies(packageJsonPath) : [];
110
+ return {
111
+ configFile,
112
+ projectDir,
113
+ pinnedVersion,
114
+ packageJsonPath,
115
+ dependencies,
116
+ mismatches: pinnedVersion ? findMismatches({
117
+ pinnedVersion,
118
+ dependencies
119
+ }) : []
120
+ };
121
+ }
122
+
123
+ //#endregion
124
+ export { rewriteFormatDependencies as a, mayHaveBreakingChanges as i, isExactVersion as n, isNewer as r, loadProjectState as t };
@@ -0,0 +1,2 @@
1
+ import { t as drawRandomName } from "./draw-random-name-BzvSSVqO.mjs";
2
+ export { drawRandomName };
@@ -0,0 +1,3 @@
1
+ import { t as drawRandomName } from "./draw-random-name-Dpt6YmUk.mjs";
2
+
3
+ export { drawRandomName };
@@ -0,0 +1,2 @@
1
+ import { C as methodsForFramework, S as isValidDimension, _ as SUPPORTED_FRAMEWORKS, a as DEFAULT_STYLING, b as isSchemaKind, c as PAGE_SIZES, d as SCHEMA_KINDS, f as SCHEMA_LABELS, g as STYLING_SUPPORT, h as STYLING_METHODS, i as DEFAULT_SCHEMA_KIND, l as PageSize, m as STYLING_LABELS, n as DEFAULT_PAGE_SIZE_ID, o as Framework, p as STYLING_DEPENDENCIES, r as DEFAULT_PAGE_WIDTH, s as MAX_PAGE_DIMENSION, t as DEFAULT_PAGE_HEIGHT, u as SCHEMA_DEPENDENCIES, v as SchemaKind, x as isStylingMethod, y as StylingMethod } from "./shared-BD62UD5L.mjs";
2
+ export { DEFAULT_PAGE_HEIGHT, DEFAULT_PAGE_SIZE_ID, DEFAULT_PAGE_WIDTH, DEFAULT_SCHEMA_KIND, DEFAULT_STYLING, Framework, MAX_PAGE_DIMENSION, PAGE_SIZES, PageSize, SCHEMA_DEPENDENCIES, SCHEMA_KINDS, SCHEMA_LABELS, STYLING_DEPENDENCIES, STYLING_LABELS, STYLING_METHODS, STYLING_SUPPORT, SUPPORTED_FRAMEWORKS, SchemaKind, StylingMethod, isSchemaKind, isStylingMethod, isValidDimension, methodsForFramework };
@@ -0,0 +1,3 @@
1
+ import { _ as isStylingMethod, a as DEFAULT_STYLING, c as SCHEMA_DEPENDENCIES, d as STYLING_DEPENDENCIES, f as STYLING_LABELS, g as isSchemaKind, h as SUPPORTED_FRAMEWORKS, i as DEFAULT_SCHEMA_KIND, l as SCHEMA_KINDS, m as STYLING_SUPPORT, n as DEFAULT_PAGE_SIZE_ID, o as MAX_PAGE_DIMENSION, p as STYLING_METHODS, r as DEFAULT_PAGE_WIDTH, s as PAGE_SIZES, t as DEFAULT_PAGE_HEIGHT, u as SCHEMA_LABELS, v as isValidDimension, y as methodsForFramework } from "./shared-CM3vyUlL.mjs";
2
+
3
+ export { DEFAULT_PAGE_HEIGHT, DEFAULT_PAGE_SIZE_ID, DEFAULT_PAGE_WIDTH, DEFAULT_SCHEMA_KIND, DEFAULT_STYLING, MAX_PAGE_DIMENSION, PAGE_SIZES, SCHEMA_DEPENDENCIES, SCHEMA_KINDS, SCHEMA_LABELS, STYLING_DEPENDENCIES, STYLING_LABELS, STYLING_METHODS, STYLING_SUPPORT, SUPPORTED_FRAMEWORKS, isSchemaKind, isStylingMethod, isValidDimension, methodsForFramework };
@@ -0,0 +1,191 @@
1
+ import { t as drawRandomName } from "./draw-random-name-BzvSSVqO.mjs";
2
+ import { C as methodsForFramework, o as Framework, v as SchemaKind, y as StylingMethod } from "./shared-BD62UD5L.mjs";
3
+
4
+ //#region src/scaffold/document/types.d.ts
5
+ interface ScaffoldProjectConfig {
6
+ framework: Framework;
7
+ rootDir?: string;
8
+ }
9
+ type TemplateId = 'blank';
10
+ declare const DEFAULT_TEMPLATE: TemplateId;
11
+ declare const EMPTY_STYLESHEET_COMMENT = "/* Your styles go here */\n";
12
+ interface GeneratedFile {
13
+ path: string;
14
+ contents: string;
15
+ }
16
+ interface MissingDependency {
17
+ name: string;
18
+ dev: boolean;
19
+ }
20
+ interface MissingConfig {
21
+ description: string;
22
+ example?: string;
23
+ }
24
+ interface PrerequisiteReport {
25
+ method: StylingMethod;
26
+ satisfied: boolean;
27
+ missingDependencies: MissingDependency[];
28
+ missingConfig: MissingConfig[];
29
+ steps: string[];
30
+ }
31
+ interface CreateDocumentArgs {
32
+ config: ScaffoldProjectConfig;
33
+ projectRoot: string;
34
+ name: string;
35
+ styling?: StylingMethod;
36
+ template?: TemplateId;
37
+ emitSchema?: boolean;
38
+ schemaKind?: SchemaKind;
39
+ width?: number;
40
+ height?: number;
41
+ data?: unknown;
42
+ empty?: boolean;
43
+ }
44
+ interface CreateDocumentResult {
45
+ documentName: string;
46
+ documentDir: string;
47
+ filesWritten: string[];
48
+ prerequisites: PrerequisiteReport;
49
+ }
50
+ interface StyleApplication {
51
+ imports: string[];
52
+ declarations: string[];
53
+ wrapperTag?: string;
54
+ headingTag: string;
55
+ headingClass?: string;
56
+ headingClassExpr?: string;
57
+ hintTag: string;
58
+ hintClass?: string;
59
+ hintClassExpr?: string;
60
+ vueStyleBlock?: string;
61
+ }
62
+ interface ApplyStyleArgs {
63
+ framework: Framework;
64
+ documentName: string;
65
+ exportName: string;
66
+ }
67
+ interface StylingStrategy {
68
+ method: StylingMethod;
69
+ frameworks: Framework[];
70
+ files(args: ApplyStyleArgs): GeneratedFile[];
71
+ emptyFiles?(args: ApplyStyleArgs): GeneratedFile[];
72
+ apply(args: ApplyStyleArgs): StyleApplication;
73
+ checkPrerequisites(args: CheckPrerequisitesArgs): Promise<PrerequisiteReport>;
74
+ setupProject?(args: SetupProjectArgs): Promise<ProjectSetupResult>;
75
+ }
76
+ interface CheckPrerequisitesArgs {
77
+ config: ScaffoldProjectConfig;
78
+ projectRoot: string;
79
+ }
80
+ interface SetupProjectArgs {
81
+ config: ScaffoldProjectConfig;
82
+ projectRoot: string;
83
+ formatConfigPath: string;
84
+ documentsGlobBase: string;
85
+ }
86
+ interface ProjectSetupResult {
87
+ method: StylingMethod;
88
+ ok: boolean;
89
+ summary: string[];
90
+ }
91
+ //#endregion
92
+ //#region src/scaffold/document/create-document.d.ts
93
+ declare const DOCUMENTS_DIR_NAME = "documents";
94
+ interface GetDocumentsDirArgs {
95
+ projectRoot: string;
96
+ config: ScaffoldProjectConfig;
97
+ }
98
+ declare function getDocumentsDir(args: GetDocumentsDirArgs): string;
99
+ declare function readExistingDocumentNames(documentsDir: string): Promise<string[]>;
100
+ interface DocumentPlan {
101
+ documentName: string;
102
+ documentDir: string;
103
+ files: GeneratedFile[];
104
+ prerequisites: PrerequisiteReport;
105
+ projectRoot: string;
106
+ }
107
+ declare function buildDocumentPlan(args: CreateDocumentArgs): Promise<DocumentPlan>;
108
+ declare function writeDocument(plan: DocumentPlan): Promise<void>;
109
+ declare function createDocument(args: CreateDocumentArgs): Promise<CreateDocumentResult>;
110
+ //#endregion
111
+ //#region src/scaffold/document/install.d.ts
112
+ interface InstallSummary {
113
+ requested: boolean;
114
+ attempted: boolean;
115
+ ok: boolean;
116
+ packages: string[];
117
+ packageManager?: string;
118
+ message?: string;
119
+ output?: string;
120
+ }
121
+ interface MaybeInstallArgs {
122
+ wanted: boolean;
123
+ projectRoot: string;
124
+ emitSchema: boolean;
125
+ schemaKind?: SchemaKind;
126
+ missingStylingDependencies: string[];
127
+ onInstallStart?: (packages: string[]) => void;
128
+ onProgress?: (line: string) => void;
129
+ }
130
+ declare function maybeInstallDependencies(args: MaybeInstallArgs): Promise<InstallSummary>;
131
+ interface MaybeSetupProjectArgs {
132
+ wanted: boolean;
133
+ styling: string | undefined;
134
+ config: ScaffoldProjectConfig;
135
+ projectRoot: string;
136
+ formatConfigPath: string;
137
+ documentsGlobBase: string;
138
+ }
139
+ declare function maybeSetupProject(args: MaybeSetupProjectArgs): Promise<ProjectSetupResult | null>;
140
+ //#endregion
141
+ //#region src/scaffold/document/validate-name.d.ts
142
+ declare const RESERVED_DOCUMENT_NAMES: string[];
143
+ interface ValidateDocumentNameArgs {
144
+ name: string;
145
+ existingNames: string[];
146
+ }
147
+ type ValidateDocumentNameResult = {
148
+ ok: true;
149
+ } | {
150
+ ok: false;
151
+ reason: string;
152
+ suggestion?: string;
153
+ };
154
+ declare function validateDocumentName(args: ValidateDocumentNameArgs): ValidateDocumentNameResult;
155
+ interface SuggestAvailableNameArgs {
156
+ name: string;
157
+ existingNames: string[];
158
+ }
159
+ declare function suggestAvailableName(args: SuggestAvailableNameArgs): string;
160
+ //#endregion
161
+ //#region src/scaffold/document/random-name.d.ts
162
+ interface GenerateRandomNameArgs {
163
+ existingNames: string[];
164
+ maxAttempts?: number;
165
+ }
166
+ declare function generateRandomName(args: GenerateRandomNameArgs): string;
167
+ //#endregion
168
+ //#region src/scaffold/document/styling/strategies.d.ts
169
+ declare const STYLING_STRATEGIES: StylingStrategy[];
170
+ //#endregion
171
+ //#region src/scaffold/document/styling/index.d.ts
172
+ interface ResolveStylingArgs {
173
+ framework: Framework;
174
+ method: StylingMethod;
175
+ }
176
+ declare function resolveStyling(args: ResolveStylingArgs): StylingStrategy;
177
+ //#endregion
178
+ //#region src/scaffold/document/styling/prerequisites.d.ts
179
+ declare function readProjectDependencies(projectRoot: string): Promise<Set<string>>;
180
+ //#endregion
181
+ //#region src/scaffold/document/document-names.d.ts
182
+ declare const RESERVED_WORDS: Set<string>;
183
+ declare function getDocumentExportName(documentName: string): string;
184
+ declare function buildDocumentExportMap(documentNames: string[]): Map<string, string>;
185
+ //#endregion
186
+ //#region src/errors.d.ts
187
+ declare class CliError extends Error {
188
+ constructor(message: string);
189
+ }
190
+ //#endregion
191
+ export { type ApplyStyleArgs, type CheckPrerequisitesArgs, CliError, type CreateDocumentArgs, type CreateDocumentResult, DEFAULT_TEMPLATE, DOCUMENTS_DIR_NAME, type DocumentPlan, EMPTY_STYLESHEET_COMMENT, type GeneratedFile, type InstallSummary, type MaybeInstallArgs, type MaybeSetupProjectArgs, type MissingConfig, type MissingDependency, type PrerequisiteReport, type ProjectSetupResult, RESERVED_DOCUMENT_NAMES, RESERVED_WORDS, STYLING_STRATEGIES, type ScaffoldProjectConfig, type SetupProjectArgs, type StyleApplication, type StylingMethod, type StylingStrategy, type TemplateId, type ValidateDocumentNameResult, buildDocumentExportMap, buildDocumentPlan, createDocument, drawRandomName, generateRandomName, getDocumentExportName, getDocumentsDir, maybeInstallDependencies, maybeSetupProject, methodsForFramework, readExistingDocumentNames, readProjectDependencies, resolveStyling, suggestAvailableName, validateDocumentName, writeDocument };
@@ -0,0 +1,6 @@
1
+ import { s as CliError } from "./config-Dq7O4e8N.mjs";
2
+ import { _ as RESERVED_WORDS, a as DOCUMENTS_DIR_NAME, b as DEFAULT_TEMPLATE, c as getDocumentsDir, d as resolveStyling, f as STYLING_STRATEGIES, g as validateDocumentName, h as suggestAvailableName, i as generateRandomName, l as readExistingDocumentNames, m as RESERVED_DOCUMENT_NAMES, n as maybeSetupProject, o as buildDocumentPlan, p as readProjectDependencies, s as createDocument, t as maybeInstallDependencies, u as writeDocument, v as buildDocumentExportMap, x as EMPTY_STYLESHEET_COMMENT, y as getDocumentExportName } from "./install-BiDrmMgJ.mjs";
3
+ import { y as methodsForFramework } from "./shared-CM3vyUlL.mjs";
4
+ import { t as drawRandomName } from "./draw-random-name-Dpt6YmUk.mjs";
5
+
6
+ export { CliError, DEFAULT_TEMPLATE, DOCUMENTS_DIR_NAME, EMPTY_STYLESHEET_COMMENT, RESERVED_DOCUMENT_NAMES, RESERVED_WORDS, STYLING_STRATEGIES, buildDocumentExportMap, buildDocumentPlan, createDocument, drawRandomName, generateRandomName, getDocumentExportName, getDocumentsDir, maybeInstallDependencies, maybeSetupProject, methodsForFramework, readExistingDocumentNames, readProjectDependencies, resolveStyling, suggestAvailableName, validateDocumentName, writeDocument };
@@ -0,0 +1,32 @@
1
+ //#region src/scaffold/shared.d.ts
2
+ type Framework = 'react' | 'vue' | 'html';
3
+ declare const SUPPORTED_FRAMEWORKS: readonly Framework[];
4
+ type StylingMethod = 'css' | 'css-modules' | 'vue-sfc-scoped' | 'scss' | 'tailwind' | 'linaria' | 'vanilla-extract' | 'panda-css';
5
+ declare const DEFAULT_STYLING: StylingMethod;
6
+ declare const STYLING_METHODS: StylingMethod[];
7
+ declare const STYLING_SUPPORT: Record<StylingMethod, Framework[]>;
8
+ declare const STYLING_DEPENDENCIES: Record<StylingMethod, string[]>;
9
+ declare const STYLING_LABELS: Record<StylingMethod, string>;
10
+ declare function methodsForFramework(framework: Framework): StylingMethod[];
11
+ declare function isStylingMethod(value: string): value is StylingMethod;
12
+ type SchemaKind = 'zod' | 'valibot' | 'joi' | 'yup';
13
+ declare const DEFAULT_SCHEMA_KIND: SchemaKind;
14
+ declare const SCHEMA_KINDS: SchemaKind[];
15
+ declare const SCHEMA_LABELS: Record<SchemaKind, string>;
16
+ declare const SCHEMA_DEPENDENCIES: Record<SchemaKind, string>;
17
+ declare function isSchemaKind(value: string): value is SchemaKind;
18
+ interface PageSize {
19
+ id: string;
20
+ name: string;
21
+ label: string;
22
+ width: number;
23
+ height: number;
24
+ }
25
+ declare const PAGE_SIZES: PageSize[];
26
+ declare const DEFAULT_PAGE_SIZE_ID = "a4";
27
+ declare const DEFAULT_PAGE_WIDTH: number;
28
+ declare const DEFAULT_PAGE_HEIGHT: number;
29
+ declare const MAX_PAGE_DIMENSION = 20000;
30
+ declare function isValidDimension(value: number): boolean;
31
+ //#endregion
32
+ export { methodsForFramework as C, isValidDimension as S, SUPPORTED_FRAMEWORKS as _, DEFAULT_STYLING as a, isSchemaKind as b, PAGE_SIZES as c, SCHEMA_KINDS as d, SCHEMA_LABELS as f, STYLING_SUPPORT as g, STYLING_METHODS as h, DEFAULT_SCHEMA_KIND as i, PageSize as l, STYLING_LABELS as m, DEFAULT_PAGE_SIZE_ID as n, Framework as o, STYLING_DEPENDENCIES as p, DEFAULT_PAGE_WIDTH as r, MAX_PAGE_DIMENSION as s, DEFAULT_PAGE_HEIGHT as t, SCHEMA_DEPENDENCIES as u, SchemaKind as v, isStylingMethod as x, StylingMethod as y };
@@ -0,0 +1,143 @@
1
+ //#region src/scaffold/shared.ts
2
+ const SUPPORTED_FRAMEWORKS = [
3
+ "react",
4
+ "vue",
5
+ "html"
6
+ ];
7
+ const DEFAULT_STYLING = "css";
8
+ const STYLING_METHODS = [
9
+ "css",
10
+ "css-modules",
11
+ "vue-sfc-scoped",
12
+ "scss",
13
+ "tailwind",
14
+ "linaria",
15
+ "vanilla-extract",
16
+ "panda-css"
17
+ ];
18
+ const STYLING_SUPPORT = {
19
+ css: [
20
+ "react",
21
+ "vue",
22
+ "html"
23
+ ],
24
+ "css-modules": ["react", "vue"],
25
+ "vue-sfc-scoped": ["vue"],
26
+ scss: [
27
+ "react",
28
+ "vue",
29
+ "html"
30
+ ],
31
+ tailwind: [
32
+ "react",
33
+ "vue",
34
+ "html"
35
+ ],
36
+ linaria: ["react"],
37
+ "vanilla-extract": ["react"],
38
+ "panda-css": ["react", "vue"]
39
+ };
40
+ const STYLING_DEPENDENCIES = {
41
+ css: [],
42
+ "css-modules": [],
43
+ "vue-sfc-scoped": [],
44
+ scss: [],
45
+ tailwind: ["tailwindcss"],
46
+ linaria: ["@linaria/react", "@linaria/core"],
47
+ "vanilla-extract": ["@vanilla-extract/css"],
48
+ "panda-css": ["@pandacss/dev"]
49
+ };
50
+ const STYLING_LABELS = {
51
+ css: "Plain CSS",
52
+ "css-modules": "CSS Modules",
53
+ "vue-sfc-scoped": "Scoped (Vue SFC)",
54
+ scss: "SCSS",
55
+ tailwind: "Tailwind",
56
+ linaria: "Linaria",
57
+ "vanilla-extract": "Vanilla Extract",
58
+ "panda-css": "Panda CSS"
59
+ };
60
+ function methodsForFramework(framework) {
61
+ return STYLING_METHODS.filter((method) => STYLING_SUPPORT[method].includes(framework));
62
+ }
63
+ function isStylingMethod(value) {
64
+ return STYLING_METHODS.includes(value);
65
+ }
66
+ const DEFAULT_SCHEMA_KIND = "zod";
67
+ const SCHEMA_KINDS = [
68
+ "zod",
69
+ "valibot",
70
+ "joi",
71
+ "yup"
72
+ ];
73
+ const SCHEMA_LABELS = {
74
+ zod: "Zod",
75
+ valibot: "Valibot",
76
+ joi: "Joi",
77
+ yup: "Yup"
78
+ };
79
+ const SCHEMA_DEPENDENCIES = {
80
+ zod: "zod",
81
+ valibot: "valibot",
82
+ joi: "joi",
83
+ yup: "yup"
84
+ };
85
+ function isSchemaKind(value) {
86
+ return SCHEMA_KINDS.includes(value);
87
+ }
88
+ const PAGE_SIZES = [
89
+ {
90
+ id: "a3",
91
+ name: "A3",
92
+ label: "297 × 420 mm",
93
+ width: 1122.52,
94
+ height: 1587.4
95
+ },
96
+ {
97
+ id: "a4",
98
+ name: "A4",
99
+ label: "210 × 297 mm",
100
+ width: 793.71,
101
+ height: 1122.52
102
+ },
103
+ {
104
+ id: "a5",
105
+ name: "A5",
106
+ label: "148 × 210 mm",
107
+ width: 559.37,
108
+ height: 793.71
109
+ },
110
+ {
111
+ id: "letter",
112
+ name: "US Letter",
113
+ label: "8.5 × 11 in",
114
+ width: 816,
115
+ height: 1056
116
+ },
117
+ {
118
+ id: "slide-16-9",
119
+ name: "Slide 16:9",
120
+ label: "1280 × 720 px",
121
+ width: 1280,
122
+ height: 720
123
+ },
124
+ {
125
+ id: "slide-4-3",
126
+ name: "Slide 4:3",
127
+ label: "1024 × 768 px",
128
+ width: 1024,
129
+ height: 768
130
+ }
131
+ ];
132
+ const DEFAULT_PAGE_SIZE_ID = "a4";
133
+ const defaultPageSize = PAGE_SIZES.find((size) => size.id === DEFAULT_PAGE_SIZE_ID);
134
+ if (!defaultPageSize) throw new Error(`DEFAULT_PAGE_SIZE_ID "${DEFAULT_PAGE_SIZE_ID}" has no matching entry in PAGE_SIZES.`);
135
+ const DEFAULT_PAGE_WIDTH = defaultPageSize.width;
136
+ const DEFAULT_PAGE_HEIGHT = defaultPageSize.height;
137
+ const MAX_PAGE_DIMENSION = 2e4;
138
+ function isValidDimension(value) {
139
+ return Number.isFinite(value) && value > 0 && value <= MAX_PAGE_DIMENSION;
140
+ }
141
+
142
+ //#endregion
143
+ export { isStylingMethod as _, DEFAULT_STYLING as a, SCHEMA_DEPENDENCIES as c, STYLING_DEPENDENCIES as d, STYLING_LABELS as f, isSchemaKind as g, SUPPORTED_FRAMEWORKS as h, DEFAULT_SCHEMA_KIND as i, SCHEMA_KINDS as l, STYLING_SUPPORT as m, DEFAULT_PAGE_SIZE_ID as n, MAX_PAGE_DIMENSION as o, STYLING_METHODS as p, DEFAULT_PAGE_WIDTH as r, PAGE_SIZES as s, DEFAULT_PAGE_HEIGHT as t, SCHEMA_LABELS as u, isValidDimension as v, methodsForFramework as y };
package/env.d.ts ADDED
@@ -0,0 +1,99 @@
1
+ declare module '@format:*' {
2
+ const mod: any
3
+ export default mod
4
+ }
5
+
6
+ declare module '*.html' {
7
+ const html: string
8
+ export default html
9
+ }
10
+
11
+ declare module '*.module.css' {
12
+ const classes: { readonly [className: string]: string }
13
+ export default classes
14
+ }
15
+
16
+ declare module '*.module.scss' {
17
+ const classes: { readonly [className: string]: string }
18
+ export default classes
19
+ }
20
+
21
+ declare module '*.module.sass' {
22
+ const classes: { readonly [className: string]: string }
23
+ export default classes
24
+ }
25
+
26
+ declare module '*.css' {}
27
+
28
+ declare module '*.scss' {}
29
+
30
+ declare module '*.sass' {}
31
+
32
+ declare module '*.svg' {
33
+ import type * as React from 'react'
34
+
35
+ const ReactComponent: React.FunctionComponent<React.SVGProps<SVGSVGElement> & { title?: string }>
36
+
37
+ export default ReactComponent
38
+ export { ReactComponent }
39
+ }
40
+
41
+ declare module '*.svg?raw' {
42
+ const content: string
43
+ export default content
44
+ }
45
+
46
+ declare module '*.png' {
47
+ const src: string
48
+ export default src
49
+ }
50
+
51
+ declare module '*.jpg' {
52
+ const src: string
53
+ export default src
54
+ }
55
+
56
+ declare module '*.jpeg' {
57
+ const src: string
58
+ export default src
59
+ }
60
+
61
+ declare module '*.gif' {
62
+ const src: string
63
+ export default src
64
+ }
65
+
66
+ declare module '*.webp' {
67
+ const src: string
68
+ export default src
69
+ }
70
+
71
+ declare module '*.avif' {
72
+ const src: string
73
+ export default src
74
+ }
75
+
76
+ declare module '*.woff' {
77
+ const src: string
78
+ export default src
79
+ }
80
+
81
+ declare module '*.woff2' {
82
+ const src: string
83
+ export default src
84
+ }
85
+
86
+ declare module '*.ttf' {
87
+ const src: string
88
+ export default src
89
+ }
90
+
91
+ declare module '*.otf' {
92
+ const src: string
93
+ export default src
94
+ }
95
+
96
+ declare module '*.eot' {
97
+ const src: string
98
+ export default src
99
+ }