@format.dev/cli 0.0.0 → 0.1.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.
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
package/README.md CHANGED
@@ -1,32 +1,41 @@
1
1
  # @format.dev/cli
2
2
 
3
- **This is a bootstrap placeholder. It reserves the package name and does nothing else.**
3
+ This CLI exposes the `format` binary: the front door to Format. Install this package to scaffold projects, compile documents, and run the Studio dev server.
4
4
 
5
- Format is not released yet. Version `0.0.0` is not a usable version of this
6
- package: it contains no implementation, and installing it gets you an empty
7
- module.
5
+ There are two key advantages to using the Format CLI.
8
6
 
9
- ## Why it exists
7
+ 1. It pins all Format packages to a single version defined in your `format.config.json` and provides an interface to update or migrate to different versions in one command.
10
8
 
11
- npm binds a package’s trusted publisher, and its staged-publishing flow, to a
12
- package that already exists. Creating these names ahead of the first release is
13
- what lets every real release go out through a reviewed, credential-free
14
- workflow rather than through a token somebody holds.
9
+ 2. It runs `@format.dev/studio` and `@format.dev/compile` as transient dependencies that are run in memory when called on. For you this means less dependencies need to be installed at CI if they're not strictly needed.
15
10
 
16
- This version is published deliberately and deprecated immediately.
11
+ ## Install
17
12
 
18
- ## Why a bare install resolves it
13
+ ```bash
14
+ npm install @format.dev/cli --save-dev
15
+ ```
19
16
 
20
- npm creates a `latest` tag on a package’s first publish and will not remove it,
21
- so `latest` points at this placeholder until Format reaches general
22
- availability. That is why the deprecation warning is there.
17
+ ## Commands
23
18
 
24
- - Beta releases go out under the `beta` tag.
25
- - General availability is when `latest` moves to a real release.
19
+ | Command | What it does |
20
+ | --------------------- | -------------------------------------------------------------------- |
21
+ | `format dev` | Start the Format Studio dev server |
22
+ | `format compile` | Compile documents into standalone renderers |
23
+ | `format new project` | Creates a completely fresh Format setup. Recommended for fresh repos |
24
+ | `format init` | Boostraps Format into an existing repo |
25
+ | `format new document` | Scaffolds a new document |
26
+ | `format update` | Updates to the latest Format version |
27
+ | `format version` | Prints the current Format version you're using |
26
28
 
27
- ## Format
29
+ ## Documentation
28
30
 
29
- - https://format.dev
30
- - https://github.com/format-hq/format-js
31
+ The [docs](https://format.dev/docs/cli/overview) for the CLI.
31
32
 
32
- Licensed under MIT. The full text ships beside this file.
33
+ ## The lockstep model
34
+
35
+ All public Format packages release in lockstep. The `version` field in `format.config.json` pins which release your project uses, and `format update` is the most consistent way to move it up or down.
36
+
37
+ Format doesn't use the peer dependency model to enforce the dependency between our packages. It's all driven from this CLI.
38
+
39
+ ## Config
40
+
41
+ `format.config.json` is JSON. It holds your version and project settings. The `$schema` URL at `format.dev/schema/format-config.json` gives you editor autocomplete. [Docs](https://format.dev/docs/studio/configuration).
package/bin/format.mjs ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ // Committed launcher for the `format` bin. pnpm only creates a bin shim when
3
+ // the target file exists at install time, and a fresh checkout (CI) installs
4
+ // before dist/ is built — pointing `bin` straight at dist/index.mjs means no
5
+ // shim is ever created there. This file always exists, so the shim always
6
+ // links; it defers to the built CLI at run time.
7
+ const distEntry = new URL('../dist/index.mjs', import.meta.url)
8
+
9
+ try {
10
+ await import(distEntry.href)
11
+ } catch (error) {
12
+ const isMissingDist = error?.code === 'ERR_MODULE_NOT_FOUND' && error.message.includes('dist/index.mjs')
13
+
14
+ if (!isMissingDist) {
15
+ throw error
16
+ }
17
+
18
+ console.error('@format.dev/cli is not built (dist/ is missing). Run `pnpm build` from the repo root, then re-run.')
19
+ process.exit(1)
20
+ }
@@ -0,0 +1,63 @@
1
+ import fs from "node:fs/promises";
2
+ import { existsSync } from "node:fs";
3
+ import { dirname, join, resolve } from "node:path";
4
+ import { applyEdits, modify, parse, printParseErrorCode } from "jsonc-parser";
5
+
6
+ //#region src/errors.ts
7
+ var CliError = class extends Error {
8
+ constructor(message) {
9
+ super(message);
10
+ this.name = "CliError";
11
+ }
12
+ };
13
+
14
+ //#endregion
15
+ //#region src/config.ts
16
+ const DEFAULT_CONFIG_BASE_NAME = "format.config";
17
+ const CONFIG_EXTENSIONS = ["json", "jsonc"];
18
+ function findConfigPath(startDir, options) {
19
+ const baseName = options?.baseName ?? DEFAULT_CONFIG_BASE_NAME;
20
+ const names = CONFIG_EXTENSIONS.map((extension) => `${baseName}.${extension}`);
21
+ let dir = resolve(startDir);
22
+ for (;;) {
23
+ for (const name of names) {
24
+ const candidate = join(dir, name);
25
+ if (existsSync(candidate)) return candidate;
26
+ }
27
+ const parent = dirname(dir);
28
+ if (parent === dir) return null;
29
+ dir = parent;
30
+ }
31
+ }
32
+ async function readConfigFile(filepath) {
33
+ const raw = await fs.readFile(filepath, "utf8");
34
+ const errors = [];
35
+ const config = parse(raw, errors, { allowTrailingComma: true });
36
+ if (errors.length > 0) throw new CliError(`Could not parse ${filepath}: ${errors.map((error) => {
37
+ const line = raw.slice(0, error.offset).split("\n").length;
38
+ return `${printParseErrorCode(error.error)} at line ${line}`;
39
+ }).join(", ")}`);
40
+ if (typeof config !== "object" || config === null || Array.isArray(config)) throw new CliError(`Invalid Format config in ${filepath}: expected a JSON object.`);
41
+ return {
42
+ filepath,
43
+ config,
44
+ raw
45
+ };
46
+ }
47
+ async function writeConfigVersion(args) {
48
+ const { filepath, version } = args;
49
+ const raw = await fs.readFile(filepath, "utf8");
50
+ const indent = detectIndent(raw);
51
+ const edits = modify(raw, ["version"], version, { formattingOptions: {
52
+ insertSpaces: !indent.includes(" "),
53
+ tabSize: indent.includes(" ") ? 4 : indent.length
54
+ } });
55
+ await fs.writeFile(filepath, applyEdits(raw, edits), "utf8");
56
+ }
57
+ function detectIndent(raw) {
58
+ const match = raw.match(/^[ \t]+/m);
59
+ return match ? match[0] : " ";
60
+ }
61
+
62
+ //#endregion
63
+ export { readConfigFile as a, findConfigPath as i, DEFAULT_CONFIG_BASE_NAME as n, writeConfigVersion as o, detectIndent as r, CliError as s, CONFIG_EXTENSIONS as t };
@@ -0,0 +1,21 @@
1
+ //#region src/config.d.ts
2
+ declare const DEFAULT_CONFIG_BASE_NAME = "format.config";
3
+ declare const CONFIG_EXTENSIONS: string[];
4
+ interface FormatConfigFile {
5
+ filepath: string;
6
+ config: Record<string, unknown>;
7
+ raw: string;
8
+ }
9
+ interface FindConfigPathOptions {
10
+ baseName?: string;
11
+ }
12
+ declare function findConfigPath(startDir: string, options?: FindConfigPathOptions): string | null;
13
+ declare function readConfigFile(filepath: string): Promise<FormatConfigFile>;
14
+ interface WriteConfigVersionArgs {
15
+ filepath: string;
16
+ version: string;
17
+ }
18
+ declare function writeConfigVersion(args: WriteConfigVersionArgs): Promise<void>;
19
+ declare function detectIndent(raw: string): string;
20
+ //#endregion
21
+ export { CONFIG_EXTENSIONS, DEFAULT_CONFIG_BASE_NAME, FormatConfigFile, detectIndent, findConfigPath, readConfigFile, writeConfigVersion };
@@ -0,0 +1,3 @@
1
+ import { a as readConfigFile, i as findConfigPath, n as DEFAULT_CONFIG_BASE_NAME, o as writeConfigVersion, r as detectIndent, t as CONFIG_EXTENSIONS } from "./config-Dq7O4e8N.mjs";
2
+
3
+ export { CONFIG_EXTENSIONS, DEFAULT_CONFIG_BASE_NAME, detectIndent, findConfigPath, readConfigFile, writeConfigVersion };
@@ -0,0 +1,4 @@
1
+ //#region src/scaffold/document/draw-random-name.d.ts
2
+ declare function drawRandomName(): string;
3
+ //#endregion
4
+ export { drawRandomName as t };
@@ -0,0 +1,13 @@
1
+ import { animals, colors, uniqueNamesGenerator } from "unique-names-generator";
2
+
3
+ //#region src/scaffold/document/draw-random-name.ts
4
+ function drawRandomName() {
5
+ return uniqueNamesGenerator({
6
+ dictionaries: [colors, animals],
7
+ separator: "-",
8
+ style: "lowerCase"
9
+ });
10
+ }
11
+
12
+ //#endregion
13
+ export { drawRandomName as t };
@@ -0,0 +1 @@
1
+ export { };