create-next-hydra 0.3.0 → 0.4.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 +126 -27
- package/dist/add-command.d.ts +11 -0
- package/dist/add-command.d.ts.map +1 -0
- package/dist/add-command.js +75 -0
- package/dist/addition.d.ts +67 -0
- package/dist/addition.d.ts.map +1 -0
- package/dist/addition.js +422 -0
- package/dist/application-git.d.ts +20 -0
- package/dist/application-git.d.ts.map +1 -0
- package/dist/application-git.js +57 -0
- package/dist/baseline.d.ts +22 -0
- package/dist/baseline.d.ts.map +1 -0
- package/dist/baseline.js +90 -0
- package/dist/cli.js +5 -18
- package/dist/commands.d.ts +22 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +197 -0
- package/dist/composition-lint.d.ts +20 -0
- package/dist/composition-lint.d.ts.map +1 -0
- package/dist/composition-lint.js +288 -0
- package/dist/composition.d.ts +24 -0
- package/dist/composition.d.ts.map +1 -0
- package/dist/composition.js +420 -0
- package/dist/create-command.d.ts +21 -0
- package/dist/create-command.d.ts.map +1 -0
- package/dist/create-command.js +128 -0
- package/dist/demo-instrumentation.d.ts +5 -0
- package/dist/demo-instrumentation.d.ts.map +1 -0
- package/dist/demo-instrumentation.js +300 -0
- package/dist/environment.d.ts +7 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/environment.js +81 -0
- package/dist/errors.d.ts +156 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +140 -0
- package/dist/file-policy.d.ts +6 -0
- package/dist/file-policy.d.ts.map +1 -0
- package/dist/file-policy.js +38 -0
- package/dist/files.d.ts +7 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +66 -0
- package/dist/hosting.d.ts +5 -0
- package/dist/hosting.d.ts.map +1 -0
- package/dist/hosting.js +107 -0
- package/dist/index.d.ts +4 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -89
- package/dist/initialization.d.ts +14 -0
- package/dist/initialization.d.ts.map +1 -0
- package/dist/initialization.js +266 -0
- package/dist/lint-workspaces.d.ts +2 -0
- package/dist/lint-workspaces.d.ts.map +1 -0
- package/dist/lint-workspaces.js +62 -0
- package/dist/model.d.ts +143 -0
- package/dist/model.d.ts.map +1 -0
- package/dist/model.js +61 -0
- package/dist/package-catalog.d.ts +8 -0
- package/dist/package-catalog.d.ts.map +1 -0
- package/dist/package-catalog.js +61 -0
- package/dist/packages.d.ts +57 -0
- package/dist/packages.d.ts.map +1 -0
- package/dist/packages.js +237 -0
- package/dist/process-group.d.ts +5 -0
- package/dist/process-group.d.ts.map +1 -0
- package/dist/process-group.js +23 -0
- package/dist/reference-workspace-bindings.d.ts +38 -0
- package/dist/reference-workspace-bindings.d.ts.map +1 -0
- package/dist/reference-workspace-bindings.js +41 -0
- package/dist/reference-workspace.d.ts +6 -0
- package/dist/reference-workspace.d.ts.map +1 -0
- package/dist/reference-workspace.js +62 -0
- package/dist/registry.d.ts +187 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +107 -0
- package/dist/runtime.d.ts +9 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +22 -0
- package/dist/selection.d.ts +704 -0
- package/dist/selection.d.ts.map +1 -0
- package/dist/selection.js +424 -0
- package/dist/shadcn-protocol.d.ts +22 -0
- package/dist/shadcn-protocol.d.ts.map +1 -0
- package/dist/shadcn-protocol.js +13 -0
- package/dist/shadcn-worker.d.ts +2 -0
- package/dist/shadcn-worker.d.ts.map +1 -0
- package/dist/shadcn-worker.js +43 -0
- package/dist/shadcn.d.ts +22 -0
- package/dist/shadcn.d.ts.map +1 -0
- package/dist/shadcn.js +101 -0
- package/dist/source-changes.d.ts +55 -0
- package/dist/source-changes.d.ts.map +1 -0
- package/dist/source-changes.js +225 -0
- package/dist/source-inventory.d.ts +25 -0
- package/dist/source-inventory.d.ts.map +1 -0
- package/dist/source-inventory.js +212 -0
- package/dist/source-root.d.ts +4 -0
- package/dist/source-root.d.ts.map +1 -0
- package/dist/source-root.js +20 -0
- package/dist/staging.d.ts +19 -0
- package/dist/staging.d.ts.map +1 -0
- package/dist/staging.js +42 -0
- package/dist/tasks.d.ts +44 -0
- package/dist/tasks.d.ts.map +1 -0
- package/dist/tasks.js +137 -0
- package/dist/templates.d.ts +217 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +161 -0
- package/dist/test-reference-workspace.d.ts +2 -0
- package/dist/test-reference-workspace.d.ts.map +1 -0
- package/dist/test-reference-workspace.js +6 -0
- package/dist/types.d.ts +2 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/typescript-paths.d.ts +10 -0
- package/dist/typescript-paths.d.ts.map +1 -0
- package/dist/typescript-paths.js +52 -0
- package/dist/workspace-dependencies.d.ts +26 -0
- package/dist/workspace-dependencies.d.ts.map +1 -0
- package/dist/workspace-dependencies.js +478 -0
- package/dist/workspace-files.d.ts +24 -0
- package/dist/workspace-files.d.ts.map +1 -0
- package/dist/workspace-files.js +395 -0
- package/dist/workspace-lock.d.ts +12 -0
- package/dist/workspace-lock.d.ts.map +1 -0
- package/dist/workspace-lock.js +104 -0
- package/dist/workspace-snapshots.d.ts +24 -0
- package/dist/workspace-snapshots.d.ts.map +1 -0
- package/dist/workspace-snapshots.js +218 -0
- package/dist/workspace-sources.d.ts +27 -0
- package/dist/workspace-sources.d.ts.map +1 -0
- package/dist/workspace-sources.js +88 -0
- package/dist/workspace-state.d.ts +325 -0
- package/dist/workspace-state.d.ts.map +1 -0
- package/dist/workspace-state.js +571 -0
- package/dist/workspaces.d.ts +73 -0
- package/dist/workspaces.d.ts.map +1 -0
- package/dist/workspaces.js +396 -0
- package/package.json +25 -20
- package/schema/selection-definition.json +143 -4
- package/dist/clone.d.ts +0 -9
- package/dist/clone.d.ts.map +0 -1
- package/dist/clone.js +0 -19
- package/dist/composition/add.d.ts +0 -14
- package/dist/composition/add.d.ts.map +0 -1
- package/dist/composition/add.js +0 -484
- package/dist/composition/catalog.d.ts +0 -26
- package/dist/composition/catalog.d.ts.map +0 -1
- package/dist/composition/catalog.js +0 -317
- package/dist/composition/errors.d.ts +0 -5
- package/dist/composition/errors.d.ts.map +0 -1
- package/dist/composition/errors.js +0 -8
- package/dist/composition/format.d.ts +0 -6
- package/dist/composition/format.d.ts.map +0 -1
- package/dist/composition/format.js +0 -65
- package/dist/composition/install.d.ts +0 -16
- package/dist/composition/install.d.ts.map +0 -1
- package/dist/composition/install.js +0 -175
- package/dist/composition/packages.d.ts +0 -6
- package/dist/composition/packages.d.ts.map +0 -1
- package/dist/composition/packages.js +0 -55
- package/dist/composition/paths.d.ts +0 -4
- package/dist/composition/paths.d.ts.map +0 -1
- package/dist/composition/paths.js +0 -47
- package/dist/composition/planner.d.ts +0 -4
- package/dist/composition/planner.d.ts.map +0 -1
- package/dist/composition/planner.js +0 -366
- package/dist/composition/schema.d.ts +0 -294
- package/dist/composition/schema.d.ts.map +0 -1
- package/dist/composition/schema.js +0 -166
- package/dist/composition/types.d.ts +0 -111
- package/dist/composition/types.d.ts.map +0 -1
- package/dist/composition/types.js +0 -6
- package/dist/composition/typescript-paths.d.ts +0 -6
- package/dist/composition/typescript-paths.d.ts.map +0 -1
- package/dist/composition/typescript-paths.js +0 -157
- package/dist/composition/use.d.ts +0 -23
- package/dist/composition/use.d.ts.map +0 -1
- package/dist/composition/use.js +0 -187
- package/dist/composition/workspace.d.ts +0 -10
- package/dist/composition/workspace.d.ts.map +0 -1
- package/dist/composition/workspace.js +0 -210
- package/dist/constants.d.ts +0 -11
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -39
- package/dist/fs-utils.d.ts +0 -9
- package/dist/fs-utils.d.ts.map +0 -1
- package/dist/fs-utils.js +0 -64
- package/dist/git.d.ts +0 -28
- package/dist/git.d.ts.map +0 -1
- package/dist/git.js +0 -107
- package/dist/instruction-renderer.d.ts +0 -17
- package/dist/instruction-renderer.d.ts.map +0 -1
- package/dist/instruction-renderer.js +0 -132
- package/dist/logger.d.ts +0 -13
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js +0 -26
- package/dist/prompts.d.ts +0 -7
- package/dist/prompts.d.ts.map +0 -1
- package/dist/prompts.js +0 -54
- package/dist/sanitize.d.ts +0 -10
- package/dist/sanitize.d.ts.map +0 -1
- package/dist/sanitize.js +0 -110
- package/dist/scaffold.d.ts +0 -7
- package/dist/scaffold.d.ts.map +0 -1
- package/dist/scaffold.js +0 -330
- package/dist/version.d.ts +0 -2
- package/dist/version.d.ts.map +0 -1
- package/dist/version.js +0 -2
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { applyEdits, modify, parse, printParseErrorCode } from "jsonc-parser";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { pathExists } from "../fs-utils.js";
|
|
6
|
-
import { CompositionValidationError } from "./errors.js";
|
|
7
|
-
const typeScriptConfigSchema = z
|
|
8
|
-
.object({
|
|
9
|
-
compilerOptions: z
|
|
10
|
-
.object({
|
|
11
|
-
paths: z.record(z.string(), z.array(z.string())).optional(),
|
|
12
|
-
})
|
|
13
|
-
.passthrough()
|
|
14
|
-
.optional(),
|
|
15
|
-
})
|
|
16
|
-
.passthrough();
|
|
17
|
-
const formattingOptions = {
|
|
18
|
-
eol: "\n",
|
|
19
|
-
insertFinalNewline: true,
|
|
20
|
-
insertSpaces: true,
|
|
21
|
-
tabSize: 2,
|
|
22
|
-
};
|
|
23
|
-
const parseTypeScriptConfig = (source, label) => {
|
|
24
|
-
const errors = [];
|
|
25
|
-
// SAFETY: jsonc-parser types its decoded JSON value as any; Zod validates it
|
|
26
|
-
// immediately below before it enters the composition domain.
|
|
27
|
-
const value = parse(source, errors, {
|
|
28
|
-
allowTrailingComma: true,
|
|
29
|
-
disallowComments: false,
|
|
30
|
-
});
|
|
31
|
-
if (errors.length > 0) {
|
|
32
|
-
throw new CompositionValidationError(`${label} is not valid JSONC.`, [
|
|
33
|
-
...new Set(errors.map((error) => printParseErrorCode(error.error))),
|
|
34
|
-
]);
|
|
35
|
-
}
|
|
36
|
-
const result = typeScriptConfigSchema.safeParse(value);
|
|
37
|
-
if (!result.success) {
|
|
38
|
-
throw new CompositionValidationError(`${label} is not a valid tsconfig.json file.`, result.error.issues.map((issue) => issue.message));
|
|
39
|
-
}
|
|
40
|
-
return result.data;
|
|
41
|
-
};
|
|
42
|
-
const toPosixRelative = (from, to) => {
|
|
43
|
-
const relative = path.relative(from, to).split(path.sep).join(path.posix.sep);
|
|
44
|
-
return relative.startsWith(".") ? relative : `./${relative}`;
|
|
45
|
-
};
|
|
46
|
-
const expectedPaths = (workspaceRoot, requirement) => {
|
|
47
|
-
const consumerRoot = path.join(workspaceRoot, requirement.cwd);
|
|
48
|
-
const targetRoot = path.join(workspaceRoot, requirement.sourcePath);
|
|
49
|
-
const relativeTarget = toPosixRelative(consumerRoot, targetRoot);
|
|
50
|
-
return [
|
|
51
|
-
{ alias: requirement.alias, expected: [relativeTarget] },
|
|
52
|
-
{
|
|
53
|
-
alias: `${requirement.alias}/*`,
|
|
54
|
-
expected: [`${relativeTarget}/*`],
|
|
55
|
-
},
|
|
56
|
-
];
|
|
57
|
-
};
|
|
58
|
-
const insertBeforeWorkspaceWildcard = (properties) => {
|
|
59
|
-
const wildcardIndex = properties.indexOf("@repo/*");
|
|
60
|
-
return wildcardIndex === -1 ? properties.length : wildcardIndex;
|
|
61
|
-
};
|
|
62
|
-
const samePath = (actual, expected) => actual !== undefined &&
|
|
63
|
-
actual.length === expected.length &&
|
|
64
|
-
actual.every((value, index) => value === expected[index]);
|
|
65
|
-
const typeScriptConfigPath = (cwd) => path.posix.join(cwd, "tsconfig.json");
|
|
66
|
-
const typeScriptConfigPlans = (plan) => {
|
|
67
|
-
const byConfig = new Map();
|
|
68
|
-
for (const target of plan.catalogTypeScriptPathAliases) {
|
|
69
|
-
const config = typeScriptConfigPath(target.cwd);
|
|
70
|
-
const entry = byConfig.get(config) ?? {
|
|
71
|
-
desired: [],
|
|
72
|
-
governed: new Set(),
|
|
73
|
-
};
|
|
74
|
-
entry.governed.add(target.alias);
|
|
75
|
-
byConfig.set(config, entry);
|
|
76
|
-
}
|
|
77
|
-
for (const alias of plan.typeScriptPathAliases) {
|
|
78
|
-
const config = typeScriptConfigPath(alias.cwd);
|
|
79
|
-
const entry = byConfig.get(config) ?? {
|
|
80
|
-
desired: [],
|
|
81
|
-
governed: new Set(),
|
|
82
|
-
};
|
|
83
|
-
entry.desired.push(alias);
|
|
84
|
-
entry.governed.add(alias.alias);
|
|
85
|
-
byConfig.set(config, entry);
|
|
86
|
-
}
|
|
87
|
-
const configs = [...byConfig].map(([config, entry]) => ({
|
|
88
|
-
config,
|
|
89
|
-
desired: entry.desired,
|
|
90
|
-
governed: [...entry.governed],
|
|
91
|
-
}));
|
|
92
|
-
// eslint-disable-next-line unicorn/no-array-sort -- The newly-created array is safe to sort in place.
|
|
93
|
-
return configs.sort((left, right) => left.config.localeCompare(right.config));
|
|
94
|
-
};
|
|
95
|
-
const governedPathAliases = (alias) => [alias, `${alias}/*`];
|
|
96
|
-
export const applyTypeScriptPathAliases = async (workspaceRoot, plan) => {
|
|
97
|
-
await Promise.all(typeScriptConfigPlans(plan).map(async ({ config, desired, governed }) => {
|
|
98
|
-
const absoluteConfigPath = path.join(workspaceRoot, config);
|
|
99
|
-
if (desired.length === 0 && !(await pathExists(absoluteConfigPath))) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
let source = await readFile(absoluteConfigPath, "utf-8");
|
|
103
|
-
const configValue = parseTypeScriptConfig(source, config);
|
|
104
|
-
const paths = configValue.compilerOptions?.paths ?? {};
|
|
105
|
-
const updates = desired.flatMap((entry) => expectedPaths(workspaceRoot, entry));
|
|
106
|
-
const desiredAliases = new Set(desired.map((entry) => entry.alias));
|
|
107
|
-
const removals = governed
|
|
108
|
-
.filter((alias) => !desiredAliases.has(alias))
|
|
109
|
-
.flatMap(governedPathAliases)
|
|
110
|
-
.filter((alias) => paths[alias] !== undefined);
|
|
111
|
-
if (removals.length === 0 &&
|
|
112
|
-
updates.every(({ alias, expected }) => samePath(paths[alias], expected))) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
for (const alias of removals) {
|
|
116
|
-
source = applyEdits(source, modify(source, ["compilerOptions", "paths", alias], undefined, {
|
|
117
|
-
formattingOptions,
|
|
118
|
-
}));
|
|
119
|
-
}
|
|
120
|
-
for (const { alias, expected } of updates) {
|
|
121
|
-
source = applyEdits(source, modify(source, ["compilerOptions", "paths", alias], expected, {
|
|
122
|
-
formattingOptions,
|
|
123
|
-
getInsertionIndex: insertBeforeWorkspaceWildcard,
|
|
124
|
-
}));
|
|
125
|
-
}
|
|
126
|
-
await writeFile(absoluteConfigPath, source, "utf-8");
|
|
127
|
-
}));
|
|
128
|
-
};
|
|
129
|
-
export const checkTypeScriptPathAliases = async (workspaceRoot, plan) => {
|
|
130
|
-
const issues = await Promise.all(typeScriptConfigPlans(plan).map(async ({ config, desired, governed }) => {
|
|
131
|
-
const absoluteConfigPath = path.join(workspaceRoot, config);
|
|
132
|
-
if (!(await pathExists(absoluteConfigPath))) {
|
|
133
|
-
return desired.length === 0 ? [] : [`${config}: file is missing`];
|
|
134
|
-
}
|
|
135
|
-
const source = await readFile(absoluteConfigPath, "utf-8");
|
|
136
|
-
const configValue = parseTypeScriptConfig(source, config);
|
|
137
|
-
const paths = configValue.compilerOptions?.paths ?? {};
|
|
138
|
-
const desiredAliases = new Set(desired.map((entry) => entry.alias));
|
|
139
|
-
const pathIssues = desired
|
|
140
|
-
.flatMap((entry) => expectedPaths(workspaceRoot, entry))
|
|
141
|
-
.filter(({ alias, expected }) => !samePath(paths[alias], expected))
|
|
142
|
-
.map(({ alias, expected }) => `${config}: expected compilerOptions.paths.${alias} to be ${JSON.stringify(expected)}`);
|
|
143
|
-
const stalePathIssues = governed
|
|
144
|
-
.filter((alias) => !desiredAliases.has(alias))
|
|
145
|
-
.flatMap(governedPathAliases)
|
|
146
|
-
.flatMap((alias) => {
|
|
147
|
-
const actual = paths[alias];
|
|
148
|
-
return actual === undefined
|
|
149
|
-
? []
|
|
150
|
-
: [
|
|
151
|
-
`${config}: expected compilerOptions.paths.${alias} to be absent, found ${JSON.stringify(actual)}`,
|
|
152
|
-
];
|
|
153
|
-
});
|
|
154
|
-
return [...pathIssues, ...stalePathIssues];
|
|
155
|
-
}));
|
|
156
|
-
return issues.flat();
|
|
157
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { confirm } from "@clack/prompts";
|
|
2
|
-
import { runCommand } from "../git.js";
|
|
3
|
-
export type UseCompositionOptions = {
|
|
4
|
-
cwd?: string;
|
|
5
|
-
auth?: string;
|
|
6
|
-
cms?: string;
|
|
7
|
-
commerce?: string;
|
|
8
|
-
addOns?: string[];
|
|
9
|
-
preset?: string;
|
|
10
|
-
check?: boolean;
|
|
11
|
-
dryRun?: boolean;
|
|
12
|
-
yes?: boolean;
|
|
13
|
-
verbose?: boolean;
|
|
14
|
-
};
|
|
15
|
-
type ConfirmPrompt = (options: Parameters<typeof confirm>[0]) => ReturnType<typeof confirm>;
|
|
16
|
-
type UseDependencies = {
|
|
17
|
-
confirm?: ConfirmPrompt;
|
|
18
|
-
install?: (cwd: string, verbose: boolean) => Promise<void>;
|
|
19
|
-
};
|
|
20
|
-
export declare function installCompositionDependencies(cwd: string, verbose: boolean, execute?: typeof runCommand): Promise<void>;
|
|
21
|
-
export declare function useComposition(options: UseCompositionOptions, dependencies?: UseDependencies): Promise<void>;
|
|
22
|
-
export {};
|
|
23
|
-
//# sourceMappingURL=use.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../src/composition/use.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAY,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAyB,UAAU,EAAE,MAAM,WAAW,CAAC;AA2B9D,MAAM,MAAM,qBAAqB,GAAG;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,KAAK,aAAa,GAAG,CACnB,OAAO,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,KACnC,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC;AAEhC,KAAK,eAAe,GAAG;IACrB,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5D,CAAC;AA+DF,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,OAAO,UAAuB,GACtC,OAAO,CAAC,IAAI,CAAC,CAKf;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,EAC9B,YAAY,GAAE,eAAoB,GACjC,OAAO,CAAC,IAAI,CAAC,CA4Jf"}
|
package/dist/composition/use.js
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { confirm, isCancel } from "@clack/prompts";
|
|
3
|
-
import { CommandExecutionError, runCommand } from "../git.js";
|
|
4
|
-
import { info, printInstructions, success } from "../logger.js";
|
|
5
|
-
import { addCatalogReferences, loadSourceRegistryCatalog } from "./catalog.js";
|
|
6
|
-
import { CompositionValidationError } from "./errors.js";
|
|
7
|
-
import { formatCompositionPlan, formatCompositionPreview, formatCompositionResult, hasCompositionChanges, } from "./format.js";
|
|
8
|
-
import { installPreparedComposition, prepareComposition, validatePackageRequirementTargets, } from "./install.js";
|
|
9
|
-
import { planComposition, selectionFromPreset } from "./planner.js";
|
|
10
|
-
import { applyTypeScriptPathAliases } from "./typescript-paths.js";
|
|
11
|
-
import { applyPackageRequirements, applyPnpmPatches, checkWorkspaceComposition, readWorkspaceSelection, removeWorkspaceTargets, writeWorkspaceSelection, } from "./workspace.js";
|
|
12
|
-
function requestedSelection(current, options, presetSelection) {
|
|
13
|
-
const providers = presetSelection
|
|
14
|
-
? { ...presetSelection.providers }
|
|
15
|
-
: { ...current.providers };
|
|
16
|
-
const providerOverrides = {
|
|
17
|
-
auth: options.auth,
|
|
18
|
-
cms: options.cms,
|
|
19
|
-
commerce: options.commerce,
|
|
20
|
-
};
|
|
21
|
-
for (const [slot, reference] of Object.entries(providerOverrides)) {
|
|
22
|
-
if (reference) {
|
|
23
|
-
providers[slot] = reference;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const presetAddOns = presetSelection ? presetSelection.addOns : [];
|
|
27
|
-
let addOns = presetSelection ? presetAddOns : current.addOns;
|
|
28
|
-
if (options.addOns) {
|
|
29
|
-
addOns = [...presetAddOns, ...options.addOns];
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
...current,
|
|
33
|
-
addOns: [...new Set(addOns)],
|
|
34
|
-
providers,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function operationFailure(error, failed, completed, pending) {
|
|
38
|
-
let cause = error instanceof Error ? error.message : String(error);
|
|
39
|
-
if (error instanceof CommandExecutionError) {
|
|
40
|
-
const output = error.stderr.trim() || error.stdout.trim();
|
|
41
|
-
if (output) {
|
|
42
|
-
cause = `${cause}\n${output}`;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return new Error([
|
|
46
|
-
`Composition stopped while ${failed}.`,
|
|
47
|
-
`Completed: ${completed.length > 0 ? completed.join(", ") : "none"}.`,
|
|
48
|
-
`Not attempted: ${pending.length > 0 ? pending.join(", ") : "none"}.`,
|
|
49
|
-
"The workspace changes have been left in place for inspection or repair.",
|
|
50
|
-
"",
|
|
51
|
-
cause,
|
|
52
|
-
].join("\n"));
|
|
53
|
-
}
|
|
54
|
-
export async function installCompositionDependencies(cwd, verbose, execute = runCommand) {
|
|
55
|
-
await execute("pnpm", ["install", "--no-frozen-lockfile"], {
|
|
56
|
-
cwd,
|
|
57
|
-
verbose,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
export async function useComposition(options, dependencies = {}) {
|
|
61
|
-
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
62
|
-
const current = await readWorkspaceSelection(cwd);
|
|
63
|
-
if (options.check &&
|
|
64
|
-
(options.auth ||
|
|
65
|
-
options.cms ||
|
|
66
|
-
options.commerce ||
|
|
67
|
-
options.preset ||
|
|
68
|
-
options.addOns)) {
|
|
69
|
-
throw new Error("`use --check` reads next-hydra.json and accepts no selections.");
|
|
70
|
-
}
|
|
71
|
-
if (options.check && options.dryRun) {
|
|
72
|
-
throw new Error("`use --check` cannot be combined with `--dry-run`.");
|
|
73
|
-
}
|
|
74
|
-
if (options.preset && (options.auth || options.cms || options.commerce)) {
|
|
75
|
-
throw new Error("`use --preset` cannot be combined with provider flags.");
|
|
76
|
-
}
|
|
77
|
-
let catalog = await loadSourceRegistryCatalog(cwd);
|
|
78
|
-
catalog = await addCatalogReferences(catalog, [
|
|
79
|
-
...Object.values(current.providers),
|
|
80
|
-
...current.addOns,
|
|
81
|
-
...[options.auth, options.cms, options.commerce, options.preset].filter((value) => Boolean(value)),
|
|
82
|
-
...(options.addOns ?? []),
|
|
83
|
-
]);
|
|
84
|
-
const presetSelection = options.preset
|
|
85
|
-
? selectionFromPreset(catalog, options.preset)
|
|
86
|
-
: undefined;
|
|
87
|
-
const selection = options.check
|
|
88
|
-
? current
|
|
89
|
-
: requestedSelection(current, options, presetSelection);
|
|
90
|
-
catalog = await addCatalogReferences(catalog, [
|
|
91
|
-
...Object.values(selection.providers),
|
|
92
|
-
...selection.addOns,
|
|
93
|
-
]);
|
|
94
|
-
const plan = planComposition(catalog, selection);
|
|
95
|
-
const prepared = await prepareComposition(catalog, plan);
|
|
96
|
-
await validatePackageRequirementTargets(cwd, plan, prepared, plan.catalogManagedTargets);
|
|
97
|
-
if (options.check) {
|
|
98
|
-
info("Checking the maintainer workspace against next-hydra.json.");
|
|
99
|
-
if (options.verbose) {
|
|
100
|
-
info(`Composition plan:\n${formatCompositionPlan(plan)}`);
|
|
101
|
-
}
|
|
102
|
-
const drift = await checkWorkspaceComposition(cwd, plan, prepared.managedFiles);
|
|
103
|
-
if (drift.length > 0) {
|
|
104
|
-
throw new CompositionValidationError("The maintainer workspace differs from next-hydra.json.", drift);
|
|
105
|
-
}
|
|
106
|
-
success("The maintainer workspace matches next-hydra.json.");
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
info(formatCompositionPreview(current, plan.selection));
|
|
110
|
-
if (options.verbose) {
|
|
111
|
-
info(`Composition plan:\n${formatCompositionPlan(plan)}`);
|
|
112
|
-
}
|
|
113
|
-
if (!hasCompositionChanges(current, plan.selection)) {
|
|
114
|
-
success(formatCompositionResult(current, plan.selection));
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
if (options.dryRun) {
|
|
118
|
-
success("Dry run complete. No changes were made.");
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
if (!options.yes) {
|
|
122
|
-
const approved = await (dependencies.confirm ?? confirm)({
|
|
123
|
-
initialValue: false,
|
|
124
|
-
message: "Apply these composition changes?",
|
|
125
|
-
});
|
|
126
|
-
if (isCancel(approved) || !approved) {
|
|
127
|
-
throw new Error("Composition cancelled. No changes were made.");
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
const completed = [];
|
|
131
|
-
const pending = [
|
|
132
|
-
"write next-hydra.json",
|
|
133
|
-
"remove managed application files",
|
|
134
|
-
"install selected source",
|
|
135
|
-
"update package aliases",
|
|
136
|
-
"update TypeScript paths",
|
|
137
|
-
"update pnpm patches",
|
|
138
|
-
"install dependencies",
|
|
139
|
-
];
|
|
140
|
-
const runStep = async (label, operation) => {
|
|
141
|
-
pending.shift();
|
|
142
|
-
try {
|
|
143
|
-
await operation();
|
|
144
|
-
completed.push(label);
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
throw operationFailure(error, label, completed, pending);
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
await runStep("write next-hydra.json", async () => {
|
|
151
|
-
await writeWorkspaceSelection(cwd, plan.selection);
|
|
152
|
-
});
|
|
153
|
-
await runStep("remove managed application files", async () => {
|
|
154
|
-
await removeWorkspaceTargets(cwd, plan.catalogManagedTargets);
|
|
155
|
-
});
|
|
156
|
-
await runStep("install selected source", async () => {
|
|
157
|
-
await installPreparedComposition(cwd, prepared);
|
|
158
|
-
});
|
|
159
|
-
await runStep("update package aliases", async () => {
|
|
160
|
-
await applyPackageRequirements(cwd, plan);
|
|
161
|
-
});
|
|
162
|
-
await runStep("update TypeScript paths", async () => {
|
|
163
|
-
await applyTypeScriptPathAliases(cwd, plan);
|
|
164
|
-
});
|
|
165
|
-
await runStep("update pnpm patches", async () => {
|
|
166
|
-
await applyPnpmPatches(cwd, plan);
|
|
167
|
-
});
|
|
168
|
-
await runStep("install dependencies", async () => {
|
|
169
|
-
if (dependencies.install) {
|
|
170
|
-
await dependencies.install(cwd, options.verbose ?? false);
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
await installCompositionDependencies(cwd, options.verbose ?? false);
|
|
174
|
-
});
|
|
175
|
-
if (plan.instructions.length > 0) {
|
|
176
|
-
printInstructions([
|
|
177
|
-
{
|
|
178
|
-
entries: plan.instructions.map((text) => ({
|
|
179
|
-
kind: "text",
|
|
180
|
-
text,
|
|
181
|
-
})),
|
|
182
|
-
title: "Provider setup",
|
|
183
|
-
},
|
|
184
|
-
]);
|
|
185
|
-
}
|
|
186
|
-
success(formatCompositionResult(current, plan.selection));
|
|
187
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { CompositionPlan, PreparedComposition, WorkspaceSelection } from "./types.js";
|
|
2
|
-
export declare const WORKSPACE_SELECTION_FILE = "next-hydra.json";
|
|
3
|
-
export declare function readWorkspaceSelection(workspaceRoot: string): Promise<WorkspaceSelection>;
|
|
4
|
-
export declare function writeWorkspaceSelection(workspaceRoot: string, selection: WorkspaceSelection): Promise<void>;
|
|
5
|
-
export declare function applyPackageRequirements(workspaceRoot: string, plan: CompositionPlan): Promise<void>;
|
|
6
|
-
export declare function applyPackageEntries(workspaceRoot: string, requirements: CompositionPlan["packageRequirements"]): Promise<void>;
|
|
7
|
-
export declare function applyPnpmPatches(workspaceRoot: string, plan: CompositionPlan): Promise<void>;
|
|
8
|
-
export declare function removeWorkspaceTargets(workspaceRoot: string, targets: string[]): Promise<void>;
|
|
9
|
-
export declare function checkWorkspaceComposition(workspaceRoot: string, plan: CompositionPlan, managedFiles: PreparedComposition["managedFiles"]): Promise<string[]>;
|
|
10
|
-
//# sourceMappingURL=workspace.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/composition/workspace.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAGpB,eAAO,MAAM,wBAAwB,oBAAoB,CAAC;AAE1D,wBAAsB,sBAAsB,CAC1C,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,kBAAkB,CAAC,CAyB7B;AAED,wBAAsB,uBAAuB,CAC3C,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,kBAAkB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAKf;AAED,wBAAsB,wBAAwB,CAC5C,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,IAAI,CAAC,CA6Cf;AAED,wBAAsB,mBAAmB,CACvC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,eAAe,CAAC,qBAAqB,CAAC,GACnD,OAAO,CAAC,IAAI,CAAC,CAgCf;AAuBD,wBAAsB,gBAAgB,CACpC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAyBD,wBAAsB,sBAAsB,CAC1C,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,IAAI,CAAC,CAWf;AAED,wBAAsB,yBAAyB,CAC7C,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,eAAe,EACrB,YAAY,EAAE,mBAAmB,CAAC,cAAc,CAAC,GAChD,OAAO,CAAC,MAAM,EAAE,CAAC,CAuGnB"}
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import { readdir, readFile, rmdir, writeFile } from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { parseDocument } from "yaml";
|
|
4
|
-
import { pathExists, readJsonFile, removePath, writeJsonFile, } from "../fs-utils.js";
|
|
5
|
-
import { CompositionValidationError } from "./errors.js";
|
|
6
|
-
import { readPackageJson } from "./packages.js";
|
|
7
|
-
import { formatZodError, workspaceSelectionSchema } from "./schema.js";
|
|
8
|
-
import { checkTypeScriptPathAliases } from "./typescript-paths.js";
|
|
9
|
-
export const WORKSPACE_SELECTION_FILE = "next-hydra.json";
|
|
10
|
-
export async function readWorkspaceSelection(workspaceRoot) {
|
|
11
|
-
const filePath = path.join(workspaceRoot, WORKSPACE_SELECTION_FILE);
|
|
12
|
-
if (!(await pathExists(filePath))) {
|
|
13
|
-
throw new Error(`${WORKSPACE_SELECTION_FILE} was not found. The \`use\` command only operates on a Next Hydra maintainer workspace.`);
|
|
14
|
-
}
|
|
15
|
-
const value = await readJsonFile(filePath);
|
|
16
|
-
const result = workspaceSelectionSchema.safeParse(value);
|
|
17
|
-
if (!result.success) {
|
|
18
|
-
throw new CompositionValidationError(`${WORKSPACE_SELECTION_FILE} is invalid.`, formatZodError(result.error));
|
|
19
|
-
}
|
|
20
|
-
// Preserve existing top-level and nested key positions, appending only
|
|
21
|
-
// schema-defaulted keys that were absent from the file.
|
|
22
|
-
const selection = value;
|
|
23
|
-
for (const [key, defaultedValue] of Object.entries(result.data)) {
|
|
24
|
-
if (!Object.hasOwn(selection, key)) {
|
|
25
|
-
selection[key] = defaultedValue;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return value;
|
|
29
|
-
}
|
|
30
|
-
export async function writeWorkspaceSelection(workspaceRoot, selection) {
|
|
31
|
-
await writeJsonFile(path.join(workspaceRoot, WORKSPACE_SELECTION_FILE), selection);
|
|
32
|
-
}
|
|
33
|
-
export async function applyPackageRequirements(workspaceRoot, plan) {
|
|
34
|
-
const selected = new Set(plan.packageRequirements.map((requirement) => `${requirement.cwd}\0${requirement.section}\0${requirement.name}`));
|
|
35
|
-
const removals = plan.catalogPackageRequirementTargets.filter((requirement) => !selected.has(`${requirement.cwd}\0${requirement.section}\0${requirement.name}`));
|
|
36
|
-
const byManifest = new Map();
|
|
37
|
-
for (const requirement of removals) {
|
|
38
|
-
const manifest = path.posix.join(requirement.cwd, "package.json");
|
|
39
|
-
const entries = byManifest.get(manifest) ?? [];
|
|
40
|
-
entries.push(requirement);
|
|
41
|
-
byManifest.set(manifest, entries);
|
|
42
|
-
}
|
|
43
|
-
await Promise.all([...byManifest].map(async ([manifest, entries]) => {
|
|
44
|
-
const manifestPath = path.join(workspaceRoot, manifest);
|
|
45
|
-
if (!(await pathExists(manifestPath))) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const packageJson = await readPackageJson(manifestPath, manifest);
|
|
49
|
-
let changed = false;
|
|
50
|
-
for (const requirement of entries) {
|
|
51
|
-
const section = packageJson[requirement.section];
|
|
52
|
-
if (!(section && Object.hasOwn(section, requirement.name))) {
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
delete section[requirement.name];
|
|
56
|
-
changed = true;
|
|
57
|
-
}
|
|
58
|
-
if (changed) {
|
|
59
|
-
await writeJsonFile(manifestPath, packageJson);
|
|
60
|
-
}
|
|
61
|
-
}));
|
|
62
|
-
await applyPackageEntries(workspaceRoot, plan.packageRequirements);
|
|
63
|
-
}
|
|
64
|
-
export async function applyPackageEntries(workspaceRoot, requirements) {
|
|
65
|
-
const byManifest = new Map();
|
|
66
|
-
for (const requirement of requirements) {
|
|
67
|
-
const manifest = path.posix.join(requirement.cwd, "package.json");
|
|
68
|
-
const existing = byManifest.get(manifest) ?? [];
|
|
69
|
-
existing.push(requirement);
|
|
70
|
-
byManifest.set(manifest, existing);
|
|
71
|
-
}
|
|
72
|
-
await Promise.all([...byManifest].map(async ([manifest, manifestRequirements]) => {
|
|
73
|
-
const manifestPath = path.join(workspaceRoot, manifest);
|
|
74
|
-
const packageJson = await readPackageJson(manifestPath, manifest);
|
|
75
|
-
let changed = false;
|
|
76
|
-
for (const requirement of manifestRequirements) {
|
|
77
|
-
const section = packageJson[requirement.section] ?? {};
|
|
78
|
-
if (Object.hasOwn(section, requirement.name) &&
|
|
79
|
-
section[requirement.name] === requirement.specifier) {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
section[requirement.name] = requirement.specifier;
|
|
83
|
-
packageJson[requirement.section] = section;
|
|
84
|
-
changed = true;
|
|
85
|
-
}
|
|
86
|
-
if (changed) {
|
|
87
|
-
await writeJsonFile(manifestPath, packageJson);
|
|
88
|
-
}
|
|
89
|
-
}));
|
|
90
|
-
}
|
|
91
|
-
function readPnpmWorkspaceConfig(source) {
|
|
92
|
-
const document = parseDocument(source);
|
|
93
|
-
if (document.errors.length > 0) {
|
|
94
|
-
throw new CompositionValidationError("pnpm-workspace.yaml is invalid.", document.errors.map((error) => error.message));
|
|
95
|
-
}
|
|
96
|
-
return {
|
|
97
|
-
config: document.toJS(),
|
|
98
|
-
document,
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
export async function applyPnpmPatches(workspaceRoot, plan) {
|
|
102
|
-
if (plan.catalogPnpmPatches.length === 0) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
const workspaceFile = path.join(workspaceRoot, "pnpm-workspace.yaml");
|
|
106
|
-
const { config, document } = readPnpmWorkspaceConfig(await readFile(workspaceFile, "utf-8"));
|
|
107
|
-
const governedDependencies = new Set(plan.catalogPnpmPatches.map((patch) => patch.dependency));
|
|
108
|
-
const patches = Object.fromEntries(Object.entries(config.patchedDependencies ?? {}).filter(([dependency]) => !governedDependencies.has(dependency)));
|
|
109
|
-
for (const patch of plan.pnpmPatches) {
|
|
110
|
-
patches[patch.dependency] = patch.path;
|
|
111
|
-
}
|
|
112
|
-
const sortedPatches = Object.fromEntries(Object.entries(patches).sort(([left], [right]) => left.localeCompare(right)));
|
|
113
|
-
if (Object.keys(sortedPatches).length === 0) {
|
|
114
|
-
document.delete("patchedDependencies");
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
document.set("patchedDependencies", sortedPatches);
|
|
118
|
-
}
|
|
119
|
-
await writeFile(workspaceFile, document.toString(), "utf-8");
|
|
120
|
-
}
|
|
121
|
-
async function pruneEmptyParents(workspaceRoot, relativeTarget) {
|
|
122
|
-
let current = path.dirname(path.join(workspaceRoot, relativeTarget));
|
|
123
|
-
const root = path.resolve(workspaceRoot);
|
|
124
|
-
while (current.startsWith(`${root}${path.sep}`)) {
|
|
125
|
-
try {
|
|
126
|
-
// Parent directories must be checked from the leaf toward the root.
|
|
127
|
-
// oxlint-disable-next-line no-await-in-loop -- Each iteration depends on the previous parent.
|
|
128
|
-
const entries = await readdir(current);
|
|
129
|
-
if (entries.length > 0) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
await rmdir(current);
|
|
133
|
-
current = path.dirname(current);
|
|
134
|
-
}
|
|
135
|
-
catch {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
export async function removeWorkspaceTargets(workspaceRoot, targets) {
|
|
141
|
-
const deepestFirst = [...targets].sort((left, right) => right.split("/").length - left.split("/").length);
|
|
142
|
-
for (const target of deepestFirst) {
|
|
143
|
-
// Targets are deepest-first so pruning one target cannot race another.
|
|
144
|
-
// oxlint-disable-next-line no-await-in-loop -- Ordered removal keeps parent pruning deterministic.
|
|
145
|
-
await removePath(path.join(workspaceRoot, target));
|
|
146
|
-
await pruneEmptyParents(workspaceRoot, target);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
export async function checkWorkspaceComposition(workspaceRoot, plan, managedFiles) {
|
|
150
|
-
const drift = [];
|
|
151
|
-
const selected = new Set(plan.packageRequirements.map((requirement) => `${requirement.cwd}\0${requirement.section}\0${requirement.name}`));
|
|
152
|
-
const unselectedPackageDrift = await Promise.all(plan.catalogPackageRequirementTargets.map(async (requirement) => {
|
|
153
|
-
const key = `${requirement.cwd}\0${requirement.section}\0${requirement.name}`;
|
|
154
|
-
if (selected.has(key)) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
const manifest = path.posix.join(requirement.cwd, "package.json");
|
|
158
|
-
const manifestPath = path.join(workspaceRoot, manifest);
|
|
159
|
-
if (!(await pathExists(manifestPath))) {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
const packageJson = await readPackageJson(manifestPath, manifest);
|
|
163
|
-
const actual = packageJson[requirement.section]?.[requirement.name];
|
|
164
|
-
return actual === undefined
|
|
165
|
-
? undefined
|
|
166
|
-
: `${manifest}: expected unselected ${requirement.section}.${requirement.name} to be absent, found ${actual}`;
|
|
167
|
-
}));
|
|
168
|
-
drift.push(...unselectedPackageDrift.filter((issue) => issue !== undefined));
|
|
169
|
-
const selectedPackageDrift = await Promise.all(plan.packageRequirements.map(async (requirement) => {
|
|
170
|
-
const manifest = path.posix.join(requirement.cwd, "package.json");
|
|
171
|
-
const packageJson = await readPackageJson(path.join(workspaceRoot, manifest), manifest);
|
|
172
|
-
const actual = packageJson[requirement.section]?.[requirement.name];
|
|
173
|
-
return actual === requirement.specifier
|
|
174
|
-
? undefined
|
|
175
|
-
: `${manifest}: expected ${requirement.section}.${requirement.name} to be ${requirement.specifier}, found ${actual ?? "missing"}`;
|
|
176
|
-
}));
|
|
177
|
-
const typeScriptPathDrift = await checkTypeScriptPathAliases(workspaceRoot, plan);
|
|
178
|
-
drift.push(...selectedPackageDrift.filter((issue) => issue !== undefined), ...typeScriptPathDrift);
|
|
179
|
-
if (plan.catalogPnpmPatches.length > 0) {
|
|
180
|
-
const workspaceFile = path.join(workspaceRoot, "pnpm-workspace.yaml");
|
|
181
|
-
const { config } = readPnpmWorkspaceConfig(await readFile(workspaceFile, "utf-8"));
|
|
182
|
-
const selectedPatches = new Map(plan.pnpmPatches.map((patch) => [patch.dependency, patch.path]));
|
|
183
|
-
for (const patch of plan.catalogPnpmPatches) {
|
|
184
|
-
const expected = selectedPatches.get(patch.dependency);
|
|
185
|
-
const actual = config.patchedDependencies?.[patch.dependency];
|
|
186
|
-
if (actual !== expected) {
|
|
187
|
-
drift.push(`pnpm-workspace.yaml: expected patchedDependencies.${patch.dependency} to be ${expected ?? "absent"}, found ${actual ?? "missing"}`);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
const expectedManagedFiles = new Map(managedFiles.map((file) => [file.target, file.content]));
|
|
192
|
-
const managedFileDrift = await Promise.all(plan.catalogManagedTargets.map(async (target) => {
|
|
193
|
-
const filePath = path.join(workspaceRoot, target);
|
|
194
|
-
const expected = expectedManagedFiles.get(target);
|
|
195
|
-
if (!expected) {
|
|
196
|
-
return (await pathExists(filePath))
|
|
197
|
-
? `${target}: managed file should not exist for this composition`
|
|
198
|
-
: undefined;
|
|
199
|
-
}
|
|
200
|
-
if (!(await pathExists(filePath))) {
|
|
201
|
-
return `${target}: managed file is missing`;
|
|
202
|
-
}
|
|
203
|
-
const actual = await readFile(filePath, "utf-8");
|
|
204
|
-
return actual === expected
|
|
205
|
-
? undefined
|
|
206
|
-
: `${target}: managed file differs from the composition plan`;
|
|
207
|
-
}));
|
|
208
|
-
drift.push(...managedFileDrift.filter((issue) => issue !== undefined));
|
|
209
|
-
return drift.sort((left, right) => left.localeCompare(right));
|
|
210
|
-
}
|
package/dist/constants.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { StarterDefinition } from "./types.js";
|
|
2
|
-
export declare const CLI_NAME = "create-next-hydra";
|
|
3
|
-
export declare const DEFAULT_REPO_URL = "https://github.com/jakala-na/next-hydra.git";
|
|
4
|
-
export declare const DEFAULT_COMMIT_MESSAGE = "Initial commit";
|
|
5
|
-
export declare const DEFAULT_PACKAGE_MANAGER = "pnpm";
|
|
6
|
-
export declare const DEFAULT_STARTER: StarterDefinition;
|
|
7
|
-
export declare const SANITIZE_REMOVE_PATHS: readonly [".changeset", ".git", ".github/workflows/e2e.yml", ".github/workflows/registry-integrity.yml", ".github/workflows/release-create-next-hydra.yml", ".scratch", "RELEASING.md", "apps/docs", "next-hydra.json", "packages/create-next-hydra", "scripts/release-create-next-hydra.mjs", "scripts/sync-registry-files.ts"];
|
|
8
|
-
export declare const SANITIZE_REMOVE_SCRIPTS: readonly ["changeset", "changeset:status", "publish:cli", "registry:check", "registry:sync", "release:create-next-hydra", "release:create-next-hydra:dry-run", "version:cli"];
|
|
9
|
-
export declare const SANITIZE_REMOVE_ROOT_DEPENDENCIES: readonly ["@clack/prompts", "commander"];
|
|
10
|
-
export declare const SANITIZE_REMOVE_ROOT_DEV_DEPENDENCIES: readonly ["@changesets/cli"];
|
|
11
|
-
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,eAAO,MAAM,QAAQ,sBAAsB,CAAC;AAC5C,eAAO,MAAM,gBAAgB,gDAAgD,CAAC;AAC9E,eAAO,MAAM,sBAAsB,mBAAmB,CAAC;AACvD,eAAO,MAAM,uBAAuB,SAAS,CAAC;AAE9C,eAAO,MAAM,eAAe,EAAE,iBAG7B,CAAC;AAEF,eAAO,MAAM,qBAAqB,YAChC,YAAY,EACZ,MAAM,EACN,2BAA2B,EAC3B,0CAA0C,EAC1C,iDAAiD,EACjD,UAAU,EACV,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,4BAA4B,EAC5B,uCAAuC,EACvC,gCAAgC,CACxB,CAAC;AAEX,eAAO,MAAM,uBAAuB,YAClC,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,2BAA2B,EAC3B,mCAAmC,EACnC,aAAa,CACL,CAAC;AAEX,eAAO,MAAM,iCAAiC,YAC5C,gBAAgB,EAChB,WAAW,CACH,CAAC;AAEX,eAAO,MAAM,qCAAqC,YAChD,iBAAiB,CACT,CAAC"}
|
package/dist/constants.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export const CLI_NAME = "create-next-hydra";
|
|
2
|
-
export const DEFAULT_REPO_URL = "https://github.com/jakala-na/next-hydra.git";
|
|
3
|
-
export const DEFAULT_COMMIT_MESSAGE = "Initial commit";
|
|
4
|
-
export const DEFAULT_PACKAGE_MANAGER = "pnpm";
|
|
5
|
-
export const DEFAULT_STARTER = {
|
|
6
|
-
id: "default",
|
|
7
|
-
repoUrl: DEFAULT_REPO_URL,
|
|
8
|
-
};
|
|
9
|
-
export const SANITIZE_REMOVE_PATHS = [
|
|
10
|
-
".changeset",
|
|
11
|
-
".git",
|
|
12
|
-
".github/workflows/e2e.yml",
|
|
13
|
-
".github/workflows/registry-integrity.yml",
|
|
14
|
-
".github/workflows/release-create-next-hydra.yml",
|
|
15
|
-
".scratch",
|
|
16
|
-
"RELEASING.md",
|
|
17
|
-
"apps/docs",
|
|
18
|
-
"next-hydra.json",
|
|
19
|
-
"packages/create-next-hydra",
|
|
20
|
-
"scripts/release-create-next-hydra.mjs",
|
|
21
|
-
"scripts/sync-registry-files.ts",
|
|
22
|
-
];
|
|
23
|
-
export const SANITIZE_REMOVE_SCRIPTS = [
|
|
24
|
-
"changeset",
|
|
25
|
-
"changeset:status",
|
|
26
|
-
"publish:cli",
|
|
27
|
-
"registry:check",
|
|
28
|
-
"registry:sync",
|
|
29
|
-
"release:create-next-hydra",
|
|
30
|
-
"release:create-next-hydra:dry-run",
|
|
31
|
-
"version:cli",
|
|
32
|
-
];
|
|
33
|
-
export const SANITIZE_REMOVE_ROOT_DEPENDENCIES = [
|
|
34
|
-
"@clack/prompts",
|
|
35
|
-
"commander",
|
|
36
|
-
];
|
|
37
|
-
export const SANITIZE_REMOVE_ROOT_DEV_DEPENDENCIES = [
|
|
38
|
-
"@changesets/cli",
|
|
39
|
-
];
|
package/dist/fs-utils.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare function pathExists(targetPath: string): Promise<boolean>;
|
|
2
|
-
export declare function isDirectoryEmpty(targetPath: string): Promise<boolean>;
|
|
3
|
-
export declare function ensureParentDirectory(targetPath: string): Promise<void>;
|
|
4
|
-
export declare function removePath(targetPath: string): Promise<void>;
|
|
5
|
-
export declare function readJsonFile<T>(filePath: string): Promise<T>;
|
|
6
|
-
export declare function writeJsonFile(filePath: string, value: unknown): Promise<void>;
|
|
7
|
-
export declare function toDisplayPath(absolutePath: string, cwd?: string): string;
|
|
8
|
-
export declare function normalizePackageName(input: string): string;
|
|
9
|
-
//# sourceMappingURL=fs-utils.d.ts.map
|
package/dist/fs-utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fs-utils.d.ts","sourceRoot":"","sources":["../src/fs-utils.ts"],"names":[],"mappings":"AAkBA,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOrE;AAED,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQ3E;AAED,wBAAsB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAI7E;AAED,wBAAsB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAElE;AAED,wBAAsB,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAGlE;AAED,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,IAAI,CAAC,CAEf;AAED,wBAAgB,aAAa,CAC3B,YAAY,EAAE,MAAM,EACpB,GAAG,SAAgB,GAClB,MAAM,CAYR;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAiB1D"}
|