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
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import type { PlatformError } from "effect";
|
|
3
|
+
import type { RegistryItem } from "shadcn/schema";
|
|
4
|
+
import { InvalidComposition } from "./errors.ts";
|
|
5
|
+
declare const Manifest: Schema.StructWithRest<Schema.Struct<{
|
|
6
|
+
readonly dependencies: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
7
|
+
readonly devDependencies: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
8
|
+
readonly name: Schema.optionalKey<Schema.String>;
|
|
9
|
+
readonly optionalDependencies: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
10
|
+
readonly peerDependencies: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
11
|
+
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>;
|
|
12
|
+
export declare const ManifestJson: Schema.fromJsonString<Schema.StructWithRest<Schema.Struct<{
|
|
13
|
+
readonly dependencies: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
14
|
+
readonly devDependencies: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
15
|
+
readonly name: Schema.optionalKey<Schema.String>;
|
|
16
|
+
readonly optionalDependencies: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
17
|
+
readonly peerDependencies: Schema.optionalKey<Schema.$Record<Schema.String, Schema.String>>;
|
|
18
|
+
}>, readonly [Schema.$Record<Schema.String, Schema.Unknown>]>>;
|
|
19
|
+
export declare const DependencySection: Schema.Literals<readonly ["dependencies", "devDependencies", "optionalDependencies"]>;
|
|
20
|
+
export interface PackageRequirement {
|
|
21
|
+
readonly target: string;
|
|
22
|
+
readonly section: typeof DependencySection.Type;
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly specifier: string;
|
|
25
|
+
}
|
|
26
|
+
export type PackageRequirementTarget = Omit<PackageRequirement, "specifier">;
|
|
27
|
+
type RegistryRequirements = Pick<RegistryItem, "name" | "dependencies" | "devDependencies">;
|
|
28
|
+
interface RootRequirement {
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly section: "dependencies" | "devDependencies";
|
|
31
|
+
readonly specifier: string | undefined;
|
|
32
|
+
}
|
|
33
|
+
export declare const registryDependencies: (items: readonly RegistryRequirements[]) => Effect.Effect<RootRequirement[], InvalidComposition, never>;
|
|
34
|
+
interface CapturedFile {
|
|
35
|
+
readonly content: Uint8Array;
|
|
36
|
+
readonly mode: number;
|
|
37
|
+
}
|
|
38
|
+
type Capture = (file: string) => Effect.Effect<CapturedFile, PlatformError.PlatformError | InvalidComposition>;
|
|
39
|
+
export declare function internalDependencies(manifest: typeof Manifest.Type): string[];
|
|
40
|
+
interface PackageInputs {
|
|
41
|
+
readonly omittedDependencies?: ReadonlySet<string>;
|
|
42
|
+
readonly files: readonly string[];
|
|
43
|
+
readonly packageManifests: readonly string[];
|
|
44
|
+
readonly selectedManifests: ReadonlyMap<string, CapturedFile>;
|
|
45
|
+
readonly governed: ReadonlySet<string>;
|
|
46
|
+
readonly capture: Capture;
|
|
47
|
+
readonly requirements: readonly PackageRequirement[];
|
|
48
|
+
readonly ownedRequirements: readonly PackageRequirementTarget[];
|
|
49
|
+
readonly registryItems: readonly RegistryRequirements[];
|
|
50
|
+
}
|
|
51
|
+
export declare const completePackages: (args_0: PackageInputs) => Effect.Effect<{
|
|
52
|
+
baseline: Set<string>;
|
|
53
|
+
directories: string[];
|
|
54
|
+
manifests: Map<string, CapturedFile>;
|
|
55
|
+
}, InvalidComposition | Schema.SchemaError | PlatformError.PlatformError, never>;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=packages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packages.d.ts","sourceRoot":"","sources":["../src/packages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,MAAM,EAAS,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAIjD,QAAA,MAAM,QAAQ;;;;;;6DASb,CAAC;AACF,eAAO,MAAM,YAAY;;;;;;8DAAgD,CAAC;AAE1E,eAAO,MAAM,iBAAiB,uFAI5B,CAAC;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,iBAAiB,CAAC,IAAI,CAAC;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AACD,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;AAE7E,KAAK,oBAAoB,GAAG,IAAI,CAC9B,YAAY,EACZ,MAAM,GAAG,cAAc,GAAG,iBAAiB,CAC5C,CAAC;AACF,UAAU,eAAe;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,iBAAiB,CAAC;IACrD,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;AAED,eAAO,MAAM,oBAAoB,yGA0C/B,CAAC;AAuCH,UAAU,YAAY;IACpB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AACD,KAAK,OAAO,GAAG,CACb,IAAI,EAAE,MAAM,KACT,MAAM,CAAC,MAAM,CAChB,YAAY,EACZ,aAAa,CAAC,aAAa,GAAG,kBAAkB,CACjD,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,QAAQ,CAAC,IAAI,GAAG,MAAM,EAAE,CAkB7E;AAED,UAAU,aAAa;IACrB,QAAQ,CAAC,mBAAmB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACnD,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,QAAQ,CAAC,iBAAiB,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC9D,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACrD,QAAQ,CAAC,iBAAiB,EAAE,SAAS,wBAAwB,EAAE,CAAC;IAChE,QAAQ,CAAC,aAAa,EAAE,SAAS,oBAAoB,EAAE,CAAC;CACzD;AAED,eAAO,MAAM,gBAAgB;;;;gFA2L5B,CAAC"}
|
package/dist/packages.js
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { Array as EffectArray, Effect, Order, Schema } from "effect";
|
|
2
|
+
import { InvalidComposition } from "./errors.js";
|
|
3
|
+
import { eligiblePackageFile } from "./file-policy.js";
|
|
4
|
+
const Dependencies = Schema.Record(Schema.String, Schema.String);
|
|
5
|
+
const Manifest = Schema.StructWithRest(Schema.Struct({
|
|
6
|
+
dependencies: Schema.optionalKey(Dependencies),
|
|
7
|
+
devDependencies: Schema.optionalKey(Dependencies),
|
|
8
|
+
name: Schema.optionalKey(Schema.String),
|
|
9
|
+
optionalDependencies: Schema.optionalKey(Dependencies),
|
|
10
|
+
peerDependencies: Schema.optionalKey(Dependencies),
|
|
11
|
+
}), [Schema.Record(Schema.String, Schema.Unknown)]);
|
|
12
|
+
export const ManifestJson = Schema.fromJsonString(Manifest, { space: 2 });
|
|
13
|
+
export const DependencySection = Schema.Literals([
|
|
14
|
+
"dependencies",
|
|
15
|
+
"devDependencies",
|
|
16
|
+
"optionalDependencies",
|
|
17
|
+
]);
|
|
18
|
+
export const registryDependencies = Effect.fn("Composition.registryDependencies")(function* (items) {
|
|
19
|
+
const requirements = new Map();
|
|
20
|
+
for (const item of items) {
|
|
21
|
+
for (const section of ["dependencies", "devDependencies"]) {
|
|
22
|
+
for (const request of item[section] ?? []) {
|
|
23
|
+
const match = /^(?<name>(?:@[a-z0-9~][a-z0-9._~-]*\/)?[a-z0-9~][a-z0-9._~-]*)(?:@(?<specifier>\S+))?$/iu.exec(request);
|
|
24
|
+
const name = match?.groups?.name;
|
|
25
|
+
const specifier = match?.groups?.specifier;
|
|
26
|
+
if (!name) {
|
|
27
|
+
return yield* new InvalidComposition({
|
|
28
|
+
message: `${item.name}.${section} requires explicit package names: use name or name@specifier, not unnamed URLs or paths`,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const previous = requirements.get(name);
|
|
32
|
+
if (previous?.specifier &&
|
|
33
|
+
specifier &&
|
|
34
|
+
previous.specifier !== specifier) {
|
|
35
|
+
return yield* new InvalidComposition({
|
|
36
|
+
message: `Conflicting registry dependency: ${name} (${item.name})`,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
requirements.set(name, {
|
|
40
|
+
name,
|
|
41
|
+
section: previous?.section === "dependencies" ? "dependencies" : section,
|
|
42
|
+
specifier: previous?.specifier ?? specifier,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return EffectArray.sortWith([...requirements.values()], (requirement) => requirement.name, Order.String);
|
|
48
|
+
});
|
|
49
|
+
function applyRegistryDependencies(manifest, requirements) {
|
|
50
|
+
const output = { ...manifest };
|
|
51
|
+
for (const { name, section, specifier } of requirements) {
|
|
52
|
+
if (!specifier &&
|
|
53
|
+
[
|
|
54
|
+
output.dependencies,
|
|
55
|
+
output.devDependencies,
|
|
56
|
+
output.optionalDependencies,
|
|
57
|
+
output.peerDependencies,
|
|
58
|
+
].some((entries) => Object.hasOwn(entries ?? {}, name))) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const destination = section === "devDependencies" &&
|
|
62
|
+
Object.hasOwn(output.dependencies ?? {}, name)
|
|
63
|
+
? "dependencies"
|
|
64
|
+
: section;
|
|
65
|
+
output[destination] = {
|
|
66
|
+
...output[destination],
|
|
67
|
+
[name]: specifier ?? "latest",
|
|
68
|
+
};
|
|
69
|
+
const other = destination === "dependencies" ? "devDependencies" : "dependencies";
|
|
70
|
+
if (output[other]) {
|
|
71
|
+
output[other] = Object.fromEntries(Object.entries(output[other]).filter(([key]) => key !== name));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return output;
|
|
75
|
+
}
|
|
76
|
+
export function internalDependencies(manifest) {
|
|
77
|
+
return [
|
|
78
|
+
manifest.dependencies,
|
|
79
|
+
manifest.devDependencies,
|
|
80
|
+
manifest.optionalDependencies,
|
|
81
|
+
manifest.peerDependencies,
|
|
82
|
+
].flatMap((section) => Object.entries(section ?? {}).flatMap(([name, specifier]) => {
|
|
83
|
+
if (!specifier.startsWith("workspace:")) {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
return [
|
|
87
|
+
specifier.startsWith("workspace:@")
|
|
88
|
+
? specifier.slice(10, specifier.lastIndexOf("@"))
|
|
89
|
+
: name,
|
|
90
|
+
];
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
export const completePackages = Effect.fn("Composition.completePackages")(function* ({ files, packageManifests, selectedManifests, governed, capture, requirements, ownedRequirements, registryItems, omittedDependencies = new Set(), }) {
|
|
94
|
+
const rootRequirements = yield* registryDependencies(registryItems);
|
|
95
|
+
const unique = new Map();
|
|
96
|
+
for (const requirement of requirements) {
|
|
97
|
+
const rootRequirement = requirement.target === "package.json"
|
|
98
|
+
? rootRequirements.find((entry) => entry.name === requirement.name)
|
|
99
|
+
: undefined;
|
|
100
|
+
if (rootRequirement?.specifier &&
|
|
101
|
+
rootRequirement.specifier !== requirement.specifier) {
|
|
102
|
+
return yield* new InvalidComposition({
|
|
103
|
+
message: `Conflicting root dependency declarations: ${requirement.name}`,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
const key = `${requirement.target}\0${requirement.section}\0${requirement.name}`;
|
|
107
|
+
const previous = unique.get(key);
|
|
108
|
+
if (previous && previous.specifier !== requirement.specifier) {
|
|
109
|
+
return yield* new InvalidComposition({
|
|
110
|
+
message: `Conflicting package requirements: ${requirement.target} ${requirement.section}.${requirement.name} (${previous.specifier}, ${requirement.specifier})`,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
unique.set(key, requirement);
|
|
114
|
+
}
|
|
115
|
+
const outputManifests = new Map();
|
|
116
|
+
const reconcile = Effect.fn("Composition.reconcileManifest")(function* (target, file) {
|
|
117
|
+
const decoded = yield* Schema.decodeEffect(ManifestJson)(new TextDecoder().decode(file.content));
|
|
118
|
+
let manifest = { ...decoded };
|
|
119
|
+
for (const entry of ownedRequirements.filter((requirement) => requirement.target === target)) {
|
|
120
|
+
const section = manifest[entry.section];
|
|
121
|
+
if (section && Object.hasOwn(section, entry.name)) {
|
|
122
|
+
manifest[entry.section] = Object.fromEntries(Object.entries(section).filter(([name]) => name !== entry.name));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
for (const requirement of unique.values()) {
|
|
126
|
+
if (requirement.target === target) {
|
|
127
|
+
manifest[requirement.section] = {
|
|
128
|
+
...manifest[requirement.section],
|
|
129
|
+
[requirement.name]: requirement.specifier,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (target === "package.json") {
|
|
134
|
+
manifest = applyRegistryDependencies(manifest, rootRequirements);
|
|
135
|
+
}
|
|
136
|
+
for (const section of [
|
|
137
|
+
"dependencies",
|
|
138
|
+
"devDependencies",
|
|
139
|
+
"optionalDependencies",
|
|
140
|
+
"peerDependencies",
|
|
141
|
+
]) {
|
|
142
|
+
if (manifest[section]) {
|
|
143
|
+
manifest[section] = Object.fromEntries(Object.entries(manifest[section]).filter(([name]) => !omittedDependencies.has(name)));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
outputManifests.set(target, {
|
|
147
|
+
...file,
|
|
148
|
+
content: new TextEncoder().encode(`${yield* Schema.encodeEffect(ManifestJson)(manifest)}\n`),
|
|
149
|
+
});
|
|
150
|
+
return manifest;
|
|
151
|
+
});
|
|
152
|
+
const byName = new Map();
|
|
153
|
+
const manifests = new Map();
|
|
154
|
+
const packageRoots = packageManifests.map((file) => file.slice(0, -"package.json".length));
|
|
155
|
+
for (const file of packageManifests) {
|
|
156
|
+
const content = yield* capture(file);
|
|
157
|
+
const manifest = yield* Schema.decodeEffect(ManifestJson)(new TextDecoder().decode(content.content));
|
|
158
|
+
if (!manifest.name) {
|
|
159
|
+
return yield* new InvalidComposition({
|
|
160
|
+
message: `Missing package name: ${file}`,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
if (byName.has(manifest.name)) {
|
|
164
|
+
return yield* new InvalidComposition({
|
|
165
|
+
message: `Duplicate package name: ${manifest.name}`,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
byName.set(manifest.name, file);
|
|
169
|
+
manifests.set(file, manifest);
|
|
170
|
+
}
|
|
171
|
+
const pending = [];
|
|
172
|
+
for (const [target, file] of selectedManifests) {
|
|
173
|
+
const manifest = yield* reconcile(target, file);
|
|
174
|
+
if (manifest.name) {
|
|
175
|
+
byName.set(manifest.name, target);
|
|
176
|
+
}
|
|
177
|
+
manifests.set(target, manifest);
|
|
178
|
+
pending.push(...internalDependencies(manifest));
|
|
179
|
+
}
|
|
180
|
+
const selected = new Set();
|
|
181
|
+
const baseline = new Set();
|
|
182
|
+
const directories = new Set();
|
|
183
|
+
while (pending.length) {
|
|
184
|
+
const name = pending.pop();
|
|
185
|
+
if (name === undefined) {
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
if (selected.has(name)) {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
selected.add(name);
|
|
192
|
+
const manifestPath = byName.get(name);
|
|
193
|
+
if (!manifestPath) {
|
|
194
|
+
return yield* new InvalidComposition({
|
|
195
|
+
message: `Missing internal package: ${name}`,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
if (!selectedManifests.has(manifestPath)) {
|
|
199
|
+
if (governed.has(manifestPath)) {
|
|
200
|
+
return yield* new InvalidComposition({
|
|
201
|
+
message: `${name} requires its registry item to be selected`,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
const directory = manifestPath.slice(0, -"package.json".length);
|
|
205
|
+
directories.add(directory.slice(0, -1));
|
|
206
|
+
manifests.set(manifestPath, yield* reconcile(manifestPath, yield* capture(manifestPath)));
|
|
207
|
+
for (const file of files.filter((candidate) => candidate.startsWith(directory) &&
|
|
208
|
+
!packageRoots.some((other) => other !== directory &&
|
|
209
|
+
other.startsWith(directory) &&
|
|
210
|
+
candidate.startsWith(other)) &&
|
|
211
|
+
eligiblePackageFile(candidate) &&
|
|
212
|
+
!governed.has(candidate))) {
|
|
213
|
+
yield* capture(file);
|
|
214
|
+
baseline.add(file);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const manifest = manifests.get(manifestPath);
|
|
218
|
+
if (!manifest) {
|
|
219
|
+
return yield* new InvalidComposition({
|
|
220
|
+
message: `Missing manifest for ${name}`,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
pending.push(...internalDependencies(manifest));
|
|
224
|
+
}
|
|
225
|
+
for (const requirement of requirements) {
|
|
226
|
+
if (!outputManifests.has(requirement.target)) {
|
|
227
|
+
return yield* new InvalidComposition({
|
|
228
|
+
message: `Missing package requirement target: ${requirement.target}`,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return {
|
|
233
|
+
baseline,
|
|
234
|
+
directories: [...directories],
|
|
235
|
+
manifests: outputManifests,
|
|
236
|
+
};
|
|
237
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { ChildProcessSpawner } from "effect/unstable/process";
|
|
3
|
+
export declare const groupExists: (pid: number) => Effect.Effect<boolean, import("effect/Cause").UnknownError, never>;
|
|
4
|
+
export declare const confirmStopped: (handle: ChildProcessSpawner.ChildProcessHandle) => Effect.Effect<void, import("effect/Cause").UnknownError | import("effect/PlatformError").PlatformError | import("effect/Cause").TimeoutError, never>;
|
|
5
|
+
//# sourceMappingURL=process-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-group.d.ts","sourceRoot":"","sources":["../src/process-group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAInE,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,uEAWnC,CAAC;AAEL,eAAO,MAAM,cAAc,GACzB,QAAQ,mBAAmB,CAAC,kBAAkB,yJASY,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
// The Node process service creates a POSIX process group. Leader exit alone
|
|
3
|
+
// does not prove that lifecycle descendants have stopped writing.
|
|
4
|
+
export const groupExists = (pid) => Effect.try(() => {
|
|
5
|
+
try {
|
|
6
|
+
process.kill(-pid, 0);
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
if (error instanceof Error && "code" in error && error.code === "ESRCH") {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
throw error;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
export const confirmStopped = (handle) => Effect.gen(function* () {
|
|
17
|
+
if (yield* groupExists(handle.pid)) {
|
|
18
|
+
yield* handle.kill({ forceKillAfter: "100 millis" });
|
|
19
|
+
while (yield* groupExists(handle.pid)) {
|
|
20
|
+
yield* Effect.sleep("10 millis");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}).pipe(Effect.interruptible, Effect.timeout("2 seconds"));
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare const REFERENCE_WORKSPACE_NAME = "storefront-contentstack";
|
|
2
|
+
export declare const REFERENCE_PROVIDERS: {
|
|
3
|
+
readonly auth: "workos";
|
|
4
|
+
readonly cms: "contentstack";
|
|
5
|
+
readonly commerce: "commercetools";
|
|
6
|
+
readonly search: "algolia";
|
|
7
|
+
};
|
|
8
|
+
export declare const referenceBindings: readonly [{
|
|
9
|
+
readonly alias: "@repo/search-provider";
|
|
10
|
+
readonly app: "web";
|
|
11
|
+
readonly provider: "search-algolia";
|
|
12
|
+
}, {
|
|
13
|
+
readonly alias: "@repo/auth";
|
|
14
|
+
readonly app: "web";
|
|
15
|
+
readonly provider: "auth-workos";
|
|
16
|
+
}, {
|
|
17
|
+
readonly alias: "@repo/cms";
|
|
18
|
+
readonly app: "web";
|
|
19
|
+
readonly provider: "cms-contentstack";
|
|
20
|
+
}, {
|
|
21
|
+
readonly alias: "@repo/commerce-provider";
|
|
22
|
+
readonly app: "web";
|
|
23
|
+
readonly provider: "commerce-commercetools";
|
|
24
|
+
}, {
|
|
25
|
+
readonly alias: "@repo/auth";
|
|
26
|
+
readonly app: "api";
|
|
27
|
+
readonly provider: "auth-workos";
|
|
28
|
+
}, {
|
|
29
|
+
readonly alias: "@repo/commerce-provider";
|
|
30
|
+
readonly app: "api";
|
|
31
|
+
readonly provider: "commerce-commercetools";
|
|
32
|
+
}, {
|
|
33
|
+
readonly alias: "@repo/auth";
|
|
34
|
+
readonly app: "admin";
|
|
35
|
+
readonly provider: "auth-workos";
|
|
36
|
+
}];
|
|
37
|
+
export declare function assertReferenceWorkspaceBindings(workspaceRoot: string): void;
|
|
38
|
+
//# sourceMappingURL=reference-workspace-bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference-workspace-bindings.d.ts","sourceRoot":"","sources":["../src/reference-workspace-bindings.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,wBAAwB,4BAA4B,CAAC;AAClE,eAAO,MAAM,mBAAmB;;;;;CAKtB,CAAC;AACX,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgBpB,CAAC;AAIX,wBAAgB,gCAAgC,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAgB5E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { Schema } from "effect";
|
|
4
|
+
import { ManifestJson } from "./packages.js";
|
|
5
|
+
export const REFERENCE_WORKSPACE_NAME = "storefront-contentstack";
|
|
6
|
+
export const REFERENCE_PROVIDERS = {
|
|
7
|
+
auth: "workos",
|
|
8
|
+
cms: "contentstack",
|
|
9
|
+
commerce: "commercetools",
|
|
10
|
+
search: "algolia",
|
|
11
|
+
};
|
|
12
|
+
export const referenceBindings = [
|
|
13
|
+
{ alias: "@repo/search-provider", app: "web", provider: "search-algolia" },
|
|
14
|
+
{ alias: "@repo/auth", app: "web", provider: "auth-workos" },
|
|
15
|
+
{ alias: "@repo/cms", app: "web", provider: "cms-contentstack" },
|
|
16
|
+
{
|
|
17
|
+
alias: "@repo/commerce-provider",
|
|
18
|
+
app: "web",
|
|
19
|
+
provider: "commerce-commercetools",
|
|
20
|
+
},
|
|
21
|
+
{ alias: "@repo/auth", app: "api", provider: "auth-workos" },
|
|
22
|
+
{
|
|
23
|
+
alias: "@repo/commerce-provider",
|
|
24
|
+
app: "api",
|
|
25
|
+
provider: "commerce-commercetools",
|
|
26
|
+
},
|
|
27
|
+
{ alias: "@repo/auth", app: "admin", provider: "auth-workos" },
|
|
28
|
+
];
|
|
29
|
+
// Retained synchronous package export for test-runner configuration consumers.
|
|
30
|
+
// CLI orchestration uses Effect FileSystem instead; this is not a second runtime.
|
|
31
|
+
export function assertReferenceWorkspaceBindings(workspaceRoot) {
|
|
32
|
+
for (const { app, alias, provider } of referenceBindings) {
|
|
33
|
+
const appRoot = path.join(workspaceRoot, "apps", app);
|
|
34
|
+
const manifest = Schema.decodeSync(ManifestJson)(readFileSync(path.join(appRoot, "package.json"), "utf-8"));
|
|
35
|
+
if (manifest.dependencies?.[alias] !== `workspace:@repo/${provider}@*` ||
|
|
36
|
+
realpathSync(path.join(appRoot, "node_modules", alias)) !==
|
|
37
|
+
realpathSync(path.join(workspaceRoot, "packages", provider))) {
|
|
38
|
+
throw new Error(`${app}'s ${alias} must resolve to ${provider} inside ${REFERENCE_WORKSPACE_NAME}. Refresh and reinstall the reference workspace.`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Effect, FileSystem, Path, Schema } from "effect";
|
|
2
|
+
import { ChildProcessSpawner } from "effect/unstable/process";
|
|
3
|
+
import { ApplicationTaskFailed, InvalidComposition } from "./errors.ts";
|
|
4
|
+
import { Workspaces } from "./workspaces.ts";
|
|
5
|
+
export declare const testReferenceWorkspace: (sourceRoot: string) => Effect.Effect<undefined, ApplicationTaskFailed | import("./errors.ts").IncompatibleSelection | InvalidComposition | import("./errors.ts").SourceChanged | import("./errors.ts").SourceAcquisitionFailed | import("./errors.ts").SourceStorageRetained | import("./errors.ts").DestinationNotEmpty | import("./errors.ts").RegistryFailure | import("./errors.ts").StagingRetained | import("./errors.ts").RegistryWorkerFailure | import("./errors.ts").MaterializationFailed | import("./errors.ts").EnvironmentInitializationFailed | import("./errors.ts").WorkspaceBusy | import("./errors.ts").WorkspaceLockAuthorizationRequired | import("./errors.ts").WorkspaceLockChanged | import("./errors.ts").WorkspaceConflict | import("./errors.ts").WorkspaceRecoveryRequired | import("./errors.ts").WorkspaceStateInvalid | import("./errors.ts").SnapshotUnavailable | import("./errors.ts").SnapshotFailed | import("./errors.ts").DependencyInstallationFailed | Schema.SchemaError | import("effect/PlatformError").PlatformError | import("./application-git.ts").ApplicationGitFailed, FileSystem.FileSystem | Path.Path | ChildProcessSpawner.ChildProcessSpawner | Workspaces>;
|
|
6
|
+
//# sourceMappingURL=reference-workspace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reference-workspace.d.ts","sourceRoot":"","sources":["../src/reference-workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EAAgB,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAQxE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,eAAO,MAAM,sBAAsB,opCA6ElC,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Console, Effect, FileSystem, Path, Schema } from "effect";
|
|
2
|
+
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
|
|
3
|
+
import { ApplicationTaskFailed, InvalidComposition } from "./errors.js";
|
|
4
|
+
import { WorkspaceDefinition } from "./model.js";
|
|
5
|
+
import { ManifestJson } from "./packages.js";
|
|
6
|
+
import { referenceBindings, REFERENCE_PROVIDERS, REFERENCE_WORKSPACE_NAME, } from "./reference-workspace-bindings.js";
|
|
7
|
+
import { Workspaces } from "./workspaces.js";
|
|
8
|
+
export const testReferenceWorkspace = Effect.fn("WorkspaceTasks.testReference")(function* (sourceRoot) {
|
|
9
|
+
const fs = yield* FileSystem.FileSystem;
|
|
10
|
+
const path = yield* Path.Path;
|
|
11
|
+
const directory = path.join(sourceRoot, "workspaces", REFERENCE_WORKSPACE_NAME);
|
|
12
|
+
const definition = yield* fs
|
|
13
|
+
.readFileString(path.join(directory, "next-hydra.json"))
|
|
14
|
+
.pipe(Effect.flatMap(Schema.decodeEffect(Schema.fromJsonString(WorkspaceDefinition))));
|
|
15
|
+
if (["auth", "cms", "commerce", "search"].some((slot) => definition.providers[slot] !== REFERENCE_PROVIDERS[slot])) {
|
|
16
|
+
return yield* new InvalidComposition({
|
|
17
|
+
message: "Application tests require the reference storefront definition with WorkOS, Contentstack, commercetools and Algolia.",
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const workspace = yield* (yield* Workspaces).named({
|
|
21
|
+
name: REFERENCE_WORKSPACE_NAME,
|
|
22
|
+
sourceRoot,
|
|
23
|
+
});
|
|
24
|
+
const result = yield* workspace.sync({});
|
|
25
|
+
if (result.dependencies !== "current") {
|
|
26
|
+
return yield* new InvalidComposition({
|
|
27
|
+
message: "Reference workspace dependencies are not current.",
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
for (const { app, alias, provider } of referenceBindings) {
|
|
31
|
+
const appRoot = path.join(directory, "apps", app);
|
|
32
|
+
const manifest = yield* fs
|
|
33
|
+
.readFileString(path.join(appRoot, "package.json"))
|
|
34
|
+
.pipe(Effect.flatMap(Schema.decodeEffect(ManifestJson)));
|
|
35
|
+
if (manifest.dependencies?.[alias] !== `workspace:@repo/${provider}@*` ||
|
|
36
|
+
(yield* fs.realPath(path.join(appRoot, "node_modules", alias))) !==
|
|
37
|
+
(yield* fs.realPath(path.join(directory, "packages", provider)))) {
|
|
38
|
+
return yield* new InvalidComposition({
|
|
39
|
+
message: `${app}'s ${alias} must resolve to ${provider} inside ${REFERENCE_WORKSPACE_NAME}. Refresh and reinstall it before testing.`,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
yield* Console.log(`Application tests: ${REFERENCE_WORKSPACE_NAME}`);
|
|
44
|
+
const process = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
45
|
+
const code = yield* process.exitCode(ChildProcess.make("pnpm", [
|
|
46
|
+
"exec",
|
|
47
|
+
"turbo",
|
|
48
|
+
"run",
|
|
49
|
+
"test",
|
|
50
|
+
"--filter=./apps/*",
|
|
51
|
+
"--only",
|
|
52
|
+
"--continue=always",
|
|
53
|
+
], {
|
|
54
|
+
cwd: directory,
|
|
55
|
+
stderr: "inherit",
|
|
56
|
+
stdin: "inherit",
|
|
57
|
+
stdout: "inherit",
|
|
58
|
+
}));
|
|
59
|
+
if (code !== 0) {
|
|
60
|
+
return yield* new ApplicationTaskFailed({ code, directory });
|
|
61
|
+
}
|
|
62
|
+
});
|