create-next-hydra 0.3.0 → 0.4.2

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 (207) hide show
  1. package/README.md +126 -27
  2. package/dist/add-command.d.ts +11 -0
  3. package/dist/add-command.d.ts.map +1 -0
  4. package/dist/add-command.js +75 -0
  5. package/dist/addition.d.ts +67 -0
  6. package/dist/addition.d.ts.map +1 -0
  7. package/dist/addition.js +422 -0
  8. package/dist/application-git.d.ts +20 -0
  9. package/dist/application-git.d.ts.map +1 -0
  10. package/dist/application-git.js +57 -0
  11. package/dist/baseline.d.ts +22 -0
  12. package/dist/baseline.d.ts.map +1 -0
  13. package/dist/baseline.js +90 -0
  14. package/dist/cli.js +5 -18
  15. package/dist/commands.d.ts +22 -0
  16. package/dist/commands.d.ts.map +1 -0
  17. package/dist/commands.js +197 -0
  18. package/dist/composition-lint.d.ts +20 -0
  19. package/dist/composition-lint.d.ts.map +1 -0
  20. package/dist/composition-lint.js +288 -0
  21. package/dist/composition.d.ts +24 -0
  22. package/dist/composition.d.ts.map +1 -0
  23. package/dist/composition.js +420 -0
  24. package/dist/create-command.d.ts +21 -0
  25. package/dist/create-command.d.ts.map +1 -0
  26. package/dist/create-command.js +128 -0
  27. package/dist/demo-instrumentation.d.ts +5 -0
  28. package/dist/demo-instrumentation.d.ts.map +1 -0
  29. package/dist/demo-instrumentation.js +300 -0
  30. package/dist/environment.d.ts +7 -0
  31. package/dist/environment.d.ts.map +1 -0
  32. package/dist/environment.js +81 -0
  33. package/dist/errors.d.ts +156 -0
  34. package/dist/errors.d.ts.map +1 -0
  35. package/dist/errors.js +140 -0
  36. package/dist/file-policy.d.ts +6 -0
  37. package/dist/file-policy.d.ts.map +1 -0
  38. package/dist/file-policy.js +38 -0
  39. package/dist/files.d.ts +7 -0
  40. package/dist/files.d.ts.map +1 -0
  41. package/dist/files.js +66 -0
  42. package/dist/hosting.d.ts +5 -0
  43. package/dist/hosting.d.ts.map +1 -0
  44. package/dist/hosting.js +107 -0
  45. package/dist/index.d.ts +4 -6
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +17 -89
  48. package/dist/initialization.d.ts +14 -0
  49. package/dist/initialization.d.ts.map +1 -0
  50. package/dist/initialization.js +266 -0
  51. package/dist/lint-workspaces.d.ts +2 -0
  52. package/dist/lint-workspaces.d.ts.map +1 -0
  53. package/dist/lint-workspaces.js +62 -0
  54. package/dist/model.d.ts +143 -0
  55. package/dist/model.d.ts.map +1 -0
  56. package/dist/model.js +61 -0
  57. package/dist/package-catalog.d.ts +8 -0
  58. package/dist/package-catalog.d.ts.map +1 -0
  59. package/dist/package-catalog.js +61 -0
  60. package/dist/packages.d.ts +57 -0
  61. package/dist/packages.d.ts.map +1 -0
  62. package/dist/packages.js +237 -0
  63. package/dist/process-group.d.ts +5 -0
  64. package/dist/process-group.d.ts.map +1 -0
  65. package/dist/process-group.js +23 -0
  66. package/dist/reference-workspace-bindings.d.ts +38 -0
  67. package/dist/reference-workspace-bindings.d.ts.map +1 -0
  68. package/dist/reference-workspace-bindings.js +41 -0
  69. package/dist/reference-workspace.d.ts +6 -0
  70. package/dist/reference-workspace.d.ts.map +1 -0
  71. package/dist/reference-workspace.js +62 -0
  72. package/dist/registry.d.ts +187 -0
  73. package/dist/registry.d.ts.map +1 -0
  74. package/dist/registry.js +107 -0
  75. package/dist/runtime.d.ts +9 -0
  76. package/dist/runtime.d.ts.map +1 -0
  77. package/dist/runtime.js +22 -0
  78. package/dist/selection.d.ts +704 -0
  79. package/dist/selection.d.ts.map +1 -0
  80. package/dist/selection.js +424 -0
  81. package/dist/shadcn-protocol.d.ts +22 -0
  82. package/dist/shadcn-protocol.d.ts.map +1 -0
  83. package/dist/shadcn-protocol.js +13 -0
  84. package/dist/shadcn-worker.d.ts +2 -0
  85. package/dist/shadcn-worker.d.ts.map +1 -0
  86. package/dist/shadcn-worker.js +43 -0
  87. package/dist/shadcn.d.ts +22 -0
  88. package/dist/shadcn.d.ts.map +1 -0
  89. package/dist/shadcn.js +101 -0
  90. package/dist/source-changes.d.ts +55 -0
  91. package/dist/source-changes.d.ts.map +1 -0
  92. package/dist/source-changes.js +225 -0
  93. package/dist/source-inventory.d.ts +25 -0
  94. package/dist/source-inventory.d.ts.map +1 -0
  95. package/dist/source-inventory.js +212 -0
  96. package/dist/source-root.d.ts +4 -0
  97. package/dist/source-root.d.ts.map +1 -0
  98. package/dist/source-root.js +20 -0
  99. package/dist/staging.d.ts +19 -0
  100. package/dist/staging.d.ts.map +1 -0
  101. package/dist/staging.js +42 -0
  102. package/dist/tasks.d.ts +44 -0
  103. package/dist/tasks.d.ts.map +1 -0
  104. package/dist/tasks.js +137 -0
  105. package/dist/templates.d.ts +217 -0
  106. package/dist/templates.d.ts.map +1 -0
  107. package/dist/templates.js +161 -0
  108. package/dist/test-reference-workspace.d.ts +2 -0
  109. package/dist/test-reference-workspace.d.ts.map +1 -0
  110. package/dist/test-reference-workspace.js +6 -0
  111. package/dist/types.d.ts +2 -9
  112. package/dist/types.d.ts.map +1 -1
  113. package/dist/typescript-paths.d.ts +10 -0
  114. package/dist/typescript-paths.d.ts.map +1 -0
  115. package/dist/typescript-paths.js +52 -0
  116. package/dist/workspace-dependencies.d.ts +26 -0
  117. package/dist/workspace-dependencies.d.ts.map +1 -0
  118. package/dist/workspace-dependencies.js +478 -0
  119. package/dist/workspace-files.d.ts +24 -0
  120. package/dist/workspace-files.d.ts.map +1 -0
  121. package/dist/workspace-files.js +395 -0
  122. package/dist/workspace-lock.d.ts +12 -0
  123. package/dist/workspace-lock.d.ts.map +1 -0
  124. package/dist/workspace-lock.js +104 -0
  125. package/dist/workspace-snapshots.d.ts +24 -0
  126. package/dist/workspace-snapshots.d.ts.map +1 -0
  127. package/dist/workspace-snapshots.js +218 -0
  128. package/dist/workspace-sources.d.ts +27 -0
  129. package/dist/workspace-sources.d.ts.map +1 -0
  130. package/dist/workspace-sources.js +88 -0
  131. package/dist/workspace-state.d.ts +325 -0
  132. package/dist/workspace-state.d.ts.map +1 -0
  133. package/dist/workspace-state.js +571 -0
  134. package/dist/workspaces.d.ts +73 -0
  135. package/dist/workspaces.d.ts.map +1 -0
  136. package/dist/workspaces.js +396 -0
  137. package/package.json +27 -20
  138. package/schema/selection-definition.json +143 -4
  139. package/dist/clone.d.ts +0 -9
  140. package/dist/clone.d.ts.map +0 -1
  141. package/dist/clone.js +0 -19
  142. package/dist/composition/add.d.ts +0 -14
  143. package/dist/composition/add.d.ts.map +0 -1
  144. package/dist/composition/add.js +0 -484
  145. package/dist/composition/catalog.d.ts +0 -26
  146. package/dist/composition/catalog.d.ts.map +0 -1
  147. package/dist/composition/catalog.js +0 -317
  148. package/dist/composition/errors.d.ts +0 -5
  149. package/dist/composition/errors.d.ts.map +0 -1
  150. package/dist/composition/errors.js +0 -8
  151. package/dist/composition/format.d.ts +0 -6
  152. package/dist/composition/format.d.ts.map +0 -1
  153. package/dist/composition/format.js +0 -65
  154. package/dist/composition/install.d.ts +0 -16
  155. package/dist/composition/install.d.ts.map +0 -1
  156. package/dist/composition/install.js +0 -175
  157. package/dist/composition/packages.d.ts +0 -6
  158. package/dist/composition/packages.d.ts.map +0 -1
  159. package/dist/composition/packages.js +0 -55
  160. package/dist/composition/paths.d.ts +0 -4
  161. package/dist/composition/paths.d.ts.map +0 -1
  162. package/dist/composition/paths.js +0 -47
  163. package/dist/composition/planner.d.ts +0 -4
  164. package/dist/composition/planner.d.ts.map +0 -1
  165. package/dist/composition/planner.js +0 -366
  166. package/dist/composition/schema.d.ts +0 -294
  167. package/dist/composition/schema.d.ts.map +0 -1
  168. package/dist/composition/schema.js +0 -166
  169. package/dist/composition/types.d.ts +0 -111
  170. package/dist/composition/types.d.ts.map +0 -1
  171. package/dist/composition/types.js +0 -6
  172. package/dist/composition/typescript-paths.d.ts +0 -6
  173. package/dist/composition/typescript-paths.d.ts.map +0 -1
  174. package/dist/composition/typescript-paths.js +0 -157
  175. package/dist/composition/use.d.ts +0 -23
  176. package/dist/composition/use.d.ts.map +0 -1
  177. package/dist/composition/use.js +0 -187
  178. package/dist/composition/workspace.d.ts +0 -10
  179. package/dist/composition/workspace.d.ts.map +0 -1
  180. package/dist/composition/workspace.js +0 -210
  181. package/dist/constants.d.ts +0 -11
  182. package/dist/constants.d.ts.map +0 -1
  183. package/dist/constants.js +0 -39
  184. package/dist/fs-utils.d.ts +0 -9
  185. package/dist/fs-utils.d.ts.map +0 -1
  186. package/dist/fs-utils.js +0 -64
  187. package/dist/git.d.ts +0 -28
  188. package/dist/git.d.ts.map +0 -1
  189. package/dist/git.js +0 -107
  190. package/dist/instruction-renderer.d.ts +0 -17
  191. package/dist/instruction-renderer.d.ts.map +0 -1
  192. package/dist/instruction-renderer.js +0 -132
  193. package/dist/logger.d.ts +0 -13
  194. package/dist/logger.d.ts.map +0 -1
  195. package/dist/logger.js +0 -26
  196. package/dist/prompts.d.ts +0 -7
  197. package/dist/prompts.d.ts.map +0 -1
  198. package/dist/prompts.js +0 -54
  199. package/dist/sanitize.d.ts +0 -10
  200. package/dist/sanitize.d.ts.map +0 -1
  201. package/dist/sanitize.js +0 -110
  202. package/dist/scaffold.d.ts +0 -7
  203. package/dist/scaffold.d.ts.map +0 -1
  204. package/dist/scaffold.js +0 -330
  205. package/dist/version.d.ts +0 -2
  206. package/dist/version.d.ts.map +0 -1
  207. package/dist/version.js +0 -2
package/dist/fs-utils.js DELETED
@@ -1,64 +0,0 @@
1
- import { access, mkdir, readdir, readFile, rm, stat, writeFile, } from "node:fs/promises";
2
- import path from "node:path";
3
- const INVALID_PACKAGE_CHARS_REGEX = /[^a-z0-9._-]+/g;
4
- const DUPLICATE_DASHES_REGEX = /-+/g;
5
- const LEADING_PUNCTUATION_REGEX = /^[._-]+/;
6
- const TRAILING_PUNCTUATION_REGEX = /[._-]+$/;
7
- const PACKAGE_START_CHAR_REGEX = /^[a-z0-9]/;
8
- const MAX_UNSCOPED_PACKAGE_NAME_LENGTH = 214;
9
- export async function pathExists(targetPath) {
10
- try {
11
- await stat(targetPath);
12
- return true;
13
- }
14
- catch {
15
- return false;
16
- }
17
- }
18
- export async function isDirectoryEmpty(targetPath) {
19
- const targetStat = await stat(targetPath);
20
- if (!targetStat.isDirectory()) {
21
- throw new Error(`Target path exists and is not a directory: ${targetPath}`);
22
- }
23
- const entries = await readdir(targetPath);
24
- return entries.length === 0;
25
- }
26
- export async function ensureParentDirectory(targetPath) {
27
- const parentDir = path.dirname(targetPath);
28
- await mkdir(parentDir, { recursive: true });
29
- await access(parentDir);
30
- }
31
- export async function removePath(targetPath) {
32
- await rm(targetPath, { force: true, recursive: true });
33
- }
34
- export async function readJsonFile(filePath) {
35
- const raw = await readFile(filePath, "utf-8");
36
- return JSON.parse(raw);
37
- }
38
- export async function writeJsonFile(filePath, value) {
39
- await writeFile(filePath, `${JSON.stringify(value, null, 2)}\n`, "utf-8");
40
- }
41
- export function toDisplayPath(absolutePath, cwd = process.cwd()) {
42
- const relative = path.relative(cwd, absolutePath);
43
- if (!relative || relative === "") {
44
- return ".";
45
- }
46
- if (relative.startsWith("..")) {
47
- return absolutePath;
48
- }
49
- return relative;
50
- }
51
- export function normalizePackageName(input) {
52
- let value = input.trim().toLowerCase();
53
- value = value.replace(INVALID_PACKAGE_CHARS_REGEX, "-");
54
- value = value.replace(DUPLICATE_DASHES_REGEX, "-");
55
- value = value.replace(LEADING_PUNCTUATION_REGEX, "");
56
- value = value.replace(TRAILING_PUNCTUATION_REGEX, "");
57
- if (!value) {
58
- return "next-hydra-app";
59
- }
60
- if (!PACKAGE_START_CHAR_REGEX.test(value)) {
61
- value = `app-${value}`;
62
- }
63
- return value.slice(0, MAX_UNSCOPED_PACKAGE_NAME_LENGTH);
64
- }
package/dist/git.d.ts DELETED
@@ -1,28 +0,0 @@
1
- import type { GitInitResult, RunCommandResult } from "./types.js";
2
- type RunCommandOptions = {
3
- cwd?: string;
4
- env?: NodeJS.ProcessEnv;
5
- verbose?: boolean;
6
- };
7
- export declare class CommandExecutionError extends Error {
8
- readonly command: string;
9
- readonly code: number | null;
10
- readonly stdout: string;
11
- readonly stderr: string;
12
- constructor(params: {
13
- command: string;
14
- code: number | null;
15
- stdout: string;
16
- stderr: string;
17
- message?: string;
18
- });
19
- }
20
- export declare function runCommand(command: string, args: string[], options?: RunCommandOptions): Promise<RunCommandResult>;
21
- export declare function runGit(args: string[], options?: RunCommandOptions): Promise<RunCommandResult>;
22
- export declare function ensureGitInstalled(verbose?: boolean): Promise<void>;
23
- export declare function initializeGitRepository(targetPath: string, options: {
24
- commit: boolean;
25
- verbose?: boolean;
26
- }): Promise<GitInitResult>;
27
- export {};
28
- //# sourceMappingURL=git.d.ts.map
package/dist/git.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAElE,KAAK,iBAAiB,GAAG;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,YAAY,MAAM,EAAE;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,EAOA;CACF;AAED,wBAAsB,UAAU,CAC9B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,gBAAgB,CAAC,CAqD3B;AAED,wBAAsB,MAAM,CAC1B,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,gBAAgB,CAAC,CAQ3B;AAED,wBAAsB,kBAAkB,CAAC,OAAO,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAEvE;AAED,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9C,OAAO,CAAC,aAAa,CAAC,CAoCxB"}
package/dist/git.js DELETED
@@ -1,107 +0,0 @@
1
- import { spawn } from "node:child_process";
2
- import { DEFAULT_COMMIT_MESSAGE } from "./constants.js";
3
- import { formatCommand } from "./logger.js";
4
- export class CommandExecutionError extends Error {
5
- command;
6
- code;
7
- stdout;
8
- stderr;
9
- constructor(params) {
10
- super(params.message ?? `Command failed: ${params.command}`);
11
- this.name = "CommandExecutionError";
12
- this.command = params.command;
13
- this.code = params.code;
14
- this.stdout = params.stdout;
15
- this.stderr = params.stderr;
16
- }
17
- }
18
- export async function runCommand(command, args, options = {}) {
19
- const child = spawn(command, args, {
20
- cwd: options.cwd,
21
- env: {
22
- ...process.env,
23
- ...options.env,
24
- },
25
- stdio: ["ignore", "pipe", "pipe"],
26
- });
27
- let stdout = "";
28
- let stderr = "";
29
- child.stdout.on("data", (chunk) => {
30
- const text = chunk.toString();
31
- stdout += text;
32
- if (options.verbose) {
33
- process.stdout.write(text);
34
- }
35
- });
36
- child.stderr.on("data", (chunk) => {
37
- const text = chunk.toString();
38
- stderr += text;
39
- if (options.verbose) {
40
- process.stderr.write(text);
41
- }
42
- });
43
- const exitCode = await new Promise((resolve, reject) => {
44
- child.on("error", reject);
45
- child.on("close", resolve);
46
- }).catch((error) => {
47
- throw new CommandExecutionError({
48
- code: null,
49
- command: formatCommand(command, args),
50
- message: error instanceof Error ? error.message : "Failed to start command",
51
- stderr,
52
- stdout,
53
- });
54
- });
55
- if (exitCode !== 0) {
56
- throw new CommandExecutionError({
57
- code: exitCode,
58
- command: formatCommand(command, args),
59
- stderr,
60
- stdout,
61
- });
62
- }
63
- return { stderr, stdout };
64
- }
65
- export async function runGit(args, options = {}) {
66
- return await runCommand("git", args, {
67
- ...options,
68
- env: {
69
- GIT_TERMINAL_PROMPT: "0",
70
- ...options.env,
71
- },
72
- });
73
- }
74
- export async function ensureGitInstalled(verbose = false) {
75
- await runGit(["--version"], { verbose });
76
- }
77
- export async function initializeGitRepository(targetPath, options) {
78
- const verbose = options.verbose ?? false;
79
- await runGit(["init"], { cwd: targetPath, verbose });
80
- if (!options.commit) {
81
- return {
82
- committed: false,
83
- gitInitialized: true,
84
- };
85
- }
86
- await runGit(["add", "-A"], { cwd: targetPath, verbose });
87
- try {
88
- await runGit(["commit", "-m", DEFAULT_COMMIT_MESSAGE], {
89
- cwd: targetPath,
90
- verbose,
91
- });
92
- return {
93
- committed: true,
94
- gitInitialized: true,
95
- };
96
- }
97
- catch (error) {
98
- if (error instanceof CommandExecutionError) {
99
- return {
100
- commitError: error.stderr.trim() || error.stdout.trim() || error.message,
101
- committed: false,
102
- gitInitialized: true,
103
- };
104
- }
105
- throw error;
106
- }
107
- }
@@ -1,17 +0,0 @@
1
- export type InstructionEntry = {
2
- kind: "text";
3
- text: string;
4
- } | {
5
- kind: "command";
6
- command: string;
7
- };
8
- export type InstructionSection = {
9
- title: string;
10
- entries: readonly InstructionEntry[];
11
- };
12
- export type InstructionOutput = {
13
- columns?: number;
14
- isTTY: boolean;
15
- };
16
- export declare function renderInstructions(sections: readonly InstructionSection[], output: InstructionOutput): string;
17
- //# sourceMappingURL=instruction-renderer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"instruction-renderer.d.ts","sourceRoot":"","sources":["../src/instruction-renderer.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AA4JF,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,EACvC,MAAM,EAAE,iBAAiB,GACxB,MAAM,CAQR"}
@@ -1,132 +0,0 @@
1
- import { stripVTControlCharacters } from "node:util";
2
- const DEFAULT_INSTRUCTION_COLUMNS = 80;
3
- const MAX_INSTRUCTION_COLUMNS = 100;
4
- const MIN_INSTRUCTION_COLUMNS = 12;
5
- const PLAIN_INSTRUCTION_COLUMNS = 100;
6
- function printableText(value) {
7
- return stripVTControlCharacters(value).replaceAll(/\s+/g, " ").trim();
8
- }
9
- function printableWidth(value) {
10
- return [...stripVTControlCharacters(value)].length;
11
- }
12
- function splitAtWidth(value, width) {
13
- const characters = [...value];
14
- return [
15
- characters.slice(0, width).join(""),
16
- characters.slice(width).join(""),
17
- ];
18
- }
19
- function wrapText(value, width) {
20
- const normalized = printableText(value);
21
- if (!normalized) {
22
- return [];
23
- }
24
- const lines = [];
25
- let currentLine = "";
26
- for (const inputWord of normalized.split(" ")) {
27
- let word = inputWord;
28
- while (printableWidth(word) > width) {
29
- if (currentLine) {
30
- lines.push(currentLine);
31
- currentLine = "";
32
- }
33
- const [chunk, remainder] = splitAtWidth(word, width);
34
- lines.push(chunk);
35
- word = remainder;
36
- }
37
- if (!word) {
38
- continue;
39
- }
40
- if (!currentLine) {
41
- currentLine = word;
42
- continue;
43
- }
44
- if (printableWidth(`${currentLine} ${word}`) <= width) {
45
- currentLine += ` ${word}`;
46
- continue;
47
- }
48
- lines.push(currentLine);
49
- currentLine = word;
50
- }
51
- if (currentLine) {
52
- lines.push(currentLine);
53
- }
54
- return lines;
55
- }
56
- function instructionColumns(output) {
57
- if (!output.isTTY) {
58
- return PLAIN_INSTRUCTION_COLUMNS;
59
- }
60
- const columns = Number.isFinite(output.columns)
61
- ? Math.floor(output.columns ?? DEFAULT_INSTRUCTION_COLUMNS)
62
- : DEFAULT_INSTRUCTION_COLUMNS;
63
- return Math.max(MIN_INSTRUCTION_COLUMNS, Math.min(columns, MAX_INSTRUCTION_COLUMNS));
64
- }
65
- function shouldSeparateEntries(previous, current) {
66
- return Boolean(previous && !(previous.kind === "command" && current.kind === "command"));
67
- }
68
- function renderTtyInstructions(sections, columns) {
69
- const lines = ["│"];
70
- for (const [sectionIndex, section] of sections.entries()) {
71
- if (sectionIndex > 0) {
72
- lines.push("│");
73
- }
74
- lines.push(`◇ ${printableText(section.title)}`, "│");
75
- let instructionNumber = 0;
76
- for (const [entryIndex, entry] of section.entries.entries()) {
77
- if (shouldSeparateEntries(section.entries[entryIndex - 1], entry)) {
78
- lines.push("│");
79
- }
80
- if (entry.kind === "command") {
81
- lines.push(`│ $ ${printableText(entry.command)}`);
82
- continue;
83
- }
84
- instructionNumber += 1;
85
- const marker = `${instructionNumber}. `;
86
- const firstPrefix = `│ ${marker}`;
87
- const continuationPrefix = `│ ${" ".repeat(marker.length)}`;
88
- const textWidth = Math.max(1, columns - printableWidth(firstPrefix));
89
- const wrapped = wrapText(entry.text, textWidth);
90
- for (const [lineIndex, line] of wrapped.entries()) {
91
- lines.push(`${lineIndex === 0 ? firstPrefix : continuationPrefix}${line}`);
92
- }
93
- }
94
- }
95
- return `${lines.join("\n")}\n`;
96
- }
97
- function renderPlainInstructions(sections, columns) {
98
- const lines = [];
99
- for (const [sectionIndex, section] of sections.entries()) {
100
- if (sectionIndex > 0) {
101
- lines.push("");
102
- }
103
- lines.push(printableText(section.title), "");
104
- let instructionNumber = 0;
105
- for (const [entryIndex, entry] of section.entries.entries()) {
106
- if (shouldSeparateEntries(section.entries[entryIndex - 1], entry)) {
107
- lines.push("");
108
- }
109
- if (entry.kind === "command") {
110
- lines.push(`$ ${printableText(entry.command)}`);
111
- continue;
112
- }
113
- instructionNumber += 1;
114
- const marker = `${instructionNumber}. `;
115
- const continuationPrefix = " ".repeat(marker.length);
116
- const wrapped = wrapText(entry.text, columns - marker.length);
117
- for (const [lineIndex, line] of wrapped.entries()) {
118
- lines.push(`${lineIndex === 0 ? marker : continuationPrefix}${line}`);
119
- }
120
- }
121
- }
122
- return `${lines.join("\n")}\n`;
123
- }
124
- export function renderInstructions(sections, output) {
125
- if (sections.length === 0) {
126
- return "";
127
- }
128
- const columns = instructionColumns(output);
129
- return output.isTTY
130
- ? renderTtyInstructions(sections, columns)
131
- : renderPlainInstructions(sections, columns);
132
- }
package/dist/logger.d.ts DELETED
@@ -1,13 +0,0 @@
1
- import type { InstructionSection } from "./instruction-renderer.js";
2
- export declare function info(message: string): void;
3
- export declare function warn(message: string): void;
4
- export declare function success(message: string): void;
5
- export declare function printInstructions(sections: readonly InstructionSection[]): void;
6
- export declare function finish(message: string): void;
7
- export declare function createSpinner(): {
8
- start: (msg?: string) => void;
9
- stop: (msg?: string, code?: number) => void;
10
- message: (msg?: string) => void;
11
- };
12
- export declare function formatCommand(command: string, args: string[]): string;
13
- //# sourceMappingURL=logger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,SAAS,kBAAkB,EAAE,GACtC,IAAI,CAON;AAED,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE5C;AAED,wBAAgB,aAAa;;;;EAE5B;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAErE"}
package/dist/logger.js DELETED
@@ -1,26 +0,0 @@
1
- import { log, outro, spinner } from "@clack/prompts";
2
- import { renderInstructions } from "./instruction-renderer.js";
3
- export function info(message) {
4
- log.info(message);
5
- }
6
- export function warn(message) {
7
- log.warn(message);
8
- }
9
- export function success(message) {
10
- log.success(message);
11
- }
12
- export function printInstructions(sections) {
13
- process.stdout.write(renderInstructions(sections, {
14
- columns: process.stdout.columns,
15
- isTTY: process.stdout.isTTY,
16
- }));
17
- }
18
- export function finish(message) {
19
- outro(message);
20
- }
21
- export function createSpinner() {
22
- return spinner();
23
- }
24
- export function formatCommand(command, args) {
25
- return [command, ...args].join(" ");
26
- }
package/dist/prompts.d.ts DELETED
@@ -1,7 +0,0 @@
1
- import type { ProviderSlot } from "./composition/types.js";
2
- export declare class UserCancelledError extends Error {
3
- constructor();
4
- }
5
- export declare function promptForTargetDirectory(): Promise<string>;
6
- export declare function promptForProvider(slot: ProviderSlot, initialValue?: string): Promise<string>;
7
- //# sourceMappingURL=prompts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,cAGC;CACF;AAED,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,MAAM,CAAC,CAiBhE;AAyBD,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,YAAY,EAClB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,MAAM,CAAC,CAajB"}
package/dist/prompts.js DELETED
@@ -1,54 +0,0 @@
1
- import { cancel, isCancel, select, text } from "@clack/prompts";
2
- export class UserCancelledError extends Error {
3
- constructor() {
4
- super("Operation cancelled by user.");
5
- this.name = "UserCancelledError";
6
- }
7
- }
8
- export async function promptForTargetDirectory() {
9
- const result = await text({
10
- message: "Where should the project be created?",
11
- placeholder: "my-next-hydra-app",
12
- validate(value) {
13
- if (!value?.trim()) {
14
- return "Please enter a folder name.";
15
- }
16
- },
17
- });
18
- if (isCancel(result)) {
19
- cancel("Cancelled.");
20
- throw new UserCancelledError();
21
- }
22
- return result.trim();
23
- }
24
- const PROVIDER_CHOICES = {
25
- auth: [
26
- { label: "WorkOS", value: "workos" },
27
- {
28
- hint: "sign-in/out, token validation, and registration onboarding",
29
- label: "Clerk",
30
- value: "clerk",
31
- },
32
- ],
33
- cms: [
34
- {
35
- hint: "includes the Drupal backend app",
36
- label: "Drupal",
37
- value: "drupal",
38
- },
39
- { label: "Contentstack", value: "contentstack" },
40
- ],
41
- commerce: [{ label: "Commercetools", value: "commercetools" }],
42
- };
43
- export async function promptForProvider(slot, initialValue) {
44
- const result = await select({
45
- initialValue,
46
- message: `Choose the ${slot} provider`,
47
- options: PROVIDER_CHOICES[slot],
48
- });
49
- if (isCancel(result)) {
50
- cancel("Cancelled.");
51
- throw new UserCancelledError();
52
- }
53
- return result;
54
- }
@@ -1,10 +0,0 @@
1
- type SanitizeStarterOptions = {
2
- targetPath: string;
3
- targetName: string;
4
- registryAuthoringPaths?: string[];
5
- };
6
- export declare function sanitizeStarter({ targetPath, targetName, registryAuthoringPaths, }: SanitizeStarterOptions): Promise<{
7
- packageName: string;
8
- }>;
9
- export {};
10
- //# sourceMappingURL=sanitize.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../src/sanitize.ts"],"names":[],"mappings":"AAmDA,KAAK,sBAAsB,GAAG;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;CACnC,CAAC;AA0GF,wBAAsB,eAAe,CAAC,EACpC,UAAU,EACV,UAAU,EACV,sBAA2B,GAC5B,EAAE,sBAAsB,GAAG,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CA+B3D"}
package/dist/sanitize.js DELETED
@@ -1,110 +0,0 @@
1
- import { createHash } from "node:crypto";
2
- import { readFile, readdir, writeFile } from "node:fs/promises";
3
- import path from "node:path";
4
- import { SANITIZE_REMOVE_PATHS, SANITIZE_REMOVE_ROOT_DEPENDENCIES, SANITIZE_REMOVE_ROOT_DEV_DEPENDENCIES, SANITIZE_REMOVE_SCRIPTS, } from "./constants.js";
5
- import { normalizePackageName, pathExists, readJsonFile, removePath, writeJsonFile, } from "./fs-utils.js";
6
- const MAINTAINER_PORTLESS_PROJECT = "next-hydra";
7
- const MAX_DNS_LABEL_LENGTH = 63;
8
- const PORTLESS_PROJECT_HASH_LENGTH = 6;
9
- const PORTLESS_PROJECT_FILES = [
10
- ".vscode/launch.json",
11
- "apps/admin/.env.example",
12
- "apps/api/.env.example",
13
- "apps/drupal/recipes/next-hydra-starter/README.md",
14
- "apps/drupal/recipes/next-hydra-starter/config/core.entity_view_display.node.article.default.yml",
15
- "apps/drupal/recipes/next-hydra-starter/config/core.entity_view_display.node.landing_page.default.yml",
16
- "apps/drupal/recipes/next-hydra-starter/config/next.next_site.next_hydra.yml",
17
- "apps/storybook/README.md",
18
- "apps/web/.env.example",
19
- "packages/cms-contentstack/README.md",
20
- "packages/cms-contentstack/cli/index.ts",
21
- "packages/cms-contentstack/cli/provisioning/provision.test.ts",
22
- "packages/cms-contentstack/cli/provisioning/recipe-live.test.ts",
23
- ];
24
- const portlessApplicationName = (applicationName, projectName) => {
25
- const [service] = applicationName.split(".");
26
- return `${service}.${projectName}`;
27
- };
28
- const portlessProjectName = (packageName) => {
29
- const sanitized = packageName
30
- .toLowerCase()
31
- .replaceAll(/[^a-z0-9-]/gu, "-")
32
- .replaceAll(/-{2,}/gu, "-")
33
- .replaceAll(/^-+|-+$/gu, "");
34
- if (sanitized.length <= MAX_DNS_LABEL_LENGTH) {
35
- return sanitized;
36
- }
37
- const hash = createHash("sha256")
38
- .update(sanitized)
39
- .digest("hex")
40
- .slice(0, PORTLESS_PROJECT_HASH_LENGTH);
41
- const prefix = sanitized
42
- .slice(0, MAX_DNS_LABEL_LENGTH - PORTLESS_PROJECT_HASH_LENGTH - 1)
43
- .replaceAll(/-+$/gu, "");
44
- return `${prefix}-${hash}`;
45
- };
46
- const rewritePackagePortlessProject = async (packageJsonPath, projectName) => {
47
- if (!(await pathExists(packageJsonPath))) {
48
- return;
49
- }
50
- const packageJson = await readJsonFile(packageJsonPath);
51
- const config = packageJson.portless;
52
- if (!config?.name) {
53
- return;
54
- }
55
- config.name = portlessApplicationName(config.name, projectName);
56
- await writeJsonFile(packageJsonPath, packageJson);
57
- };
58
- const rewriteApplicationPortlessConfigs = async (targetPath, projectName) => {
59
- const applicationsPath = path.join(targetPath, "apps");
60
- if (!(await pathExists(applicationsPath))) {
61
- return;
62
- }
63
- const applicationEntries = await readdir(applicationsPath, {
64
- withFileTypes: true,
65
- });
66
- const applicationDirectories = applicationEntries.filter((entry) => entry.isDirectory());
67
- await Promise.all(applicationDirectories.map(async ({ name }) => {
68
- await rewritePackagePortlessProject(path.join(applicationsPath, name, "package.json"), projectName);
69
- }));
70
- };
71
- const rewritePortlessProject = async (targetPath, packageName) => {
72
- const projectName = portlessProjectName(packageName);
73
- await rewriteApplicationPortlessConfigs(targetPath, projectName);
74
- const maintainerHostname = `.${MAINTAINER_PORTLESS_PROJECT}.localhost`;
75
- const projectHostname = `.${projectName}.localhost`;
76
- await Promise.all(PORTLESS_PROJECT_FILES.map(async (relativePath) => {
77
- const filePath = path.join(targetPath, relativePath);
78
- if (!(await pathExists(filePath))) {
79
- return;
80
- }
81
- const source = await readFile(filePath, "utf-8");
82
- const rewritten = source.replaceAll(maintainerHostname, projectHostname);
83
- if (rewritten !== source) {
84
- await writeFile(filePath, rewritten, "utf-8");
85
- }
86
- }));
87
- };
88
- export async function sanitizeStarter({ targetPath, targetName, registryAuthoringPaths = [], }) {
89
- await Promise.all([...SANITIZE_REMOVE_PATHS, ...registryAuthoringPaths].map(async (relativePath) => {
90
- await removePath(path.join(targetPath, relativePath));
91
- }));
92
- const packageJsonPath = path.join(targetPath, "package.json");
93
- const packageJson = await readJsonFile(packageJsonPath);
94
- const packageName = normalizePackageName(targetName);
95
- packageJson.name = packageName;
96
- for (const script of SANITIZE_REMOVE_SCRIPTS) {
97
- delete packageJson.scripts?.[script];
98
- }
99
- for (const dependency of SANITIZE_REMOVE_ROOT_DEPENDENCIES) {
100
- delete packageJson.dependencies?.[dependency];
101
- }
102
- for (const dependency of SANITIZE_REMOVE_ROOT_DEV_DEPENDENCIES) {
103
- delete packageJson.devDependencies?.[dependency];
104
- }
105
- await Promise.all([
106
- writeJsonFile(packageJsonPath, packageJson),
107
- rewritePortlessProject(targetPath, packageName),
108
- ]);
109
- return { packageName };
110
- }
@@ -1,7 +0,0 @@
1
- import type { CreateOptions, ScaffoldResult } from "./types.js";
2
- type ScaffoldDependencies = {
3
- install?: (cwd: string, verbose: boolean) => Promise<void>;
4
- };
5
- export declare function scaffoldProject(options: CreateOptions, dependencies?: ScaffoldDependencies): Promise<ScaffoldResult>;
6
- export {};
7
- //# sourceMappingURL=scaffold.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scaffold.d.ts","sourceRoot":"","sources":["../src/scaffold.ts"],"names":[],"mappings":"AAoDA,OAAO,KAAK,EACV,aAAa,EAEb,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB,KAAK,oBAAoB,GAAG;IAC1B,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5D,CAAC;AA8KF,wBAAsB,eAAe,CACnC,OAAO,EAAE,aAAa,EACtB,YAAY,GAAE,oBAAyB,GACtC,OAAO,CAAC,cAAc,CAAC,CA2OzB"}