@ykdz/template 0.0.4 → 0.0.5

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/dist/src/cli.js CHANGED
@@ -12,7 +12,7 @@ function usage() {
12
12
  return [
13
13
  "Usage:",
14
14
  " template init <dir> --preset <name> --yes",
15
- " template add package --preset <name> --name <name> [--path <package-path>]",
15
+ " template add package --preset <name> --name <name> [--path <package-path>] [--link-from <package-path>]...",
16
16
  " template presets",
17
17
  " template schema preset",
18
18
  " template schema blueprint",
@@ -23,6 +23,7 @@ function usage() {
23
23
  " --preset <name> Project preset to generate",
24
24
  " --name <name> Package name to add",
25
25
  " --path <path> Two-segment Package Path to add",
26
+ " --link-from <path> Existing consumer Package Path to link from; repeatable",
26
27
  " --scope <name> Package scope for workspace package names",
27
28
  " --yes Accept defaults for non-interactive generation",
28
29
  " --dry-run Print the planned generation without writing files",
@@ -283,6 +284,7 @@ function parseAddPackageOptions(args) {
283
284
  let preset = "";
284
285
  let name = "";
285
286
  let packagePath;
287
+ const linkFrom = [];
286
288
  for (let index = 2; index < args.length; index += 1) {
287
289
  const arg = args[index];
288
290
  if (arg === "--preset") {
@@ -312,6 +314,15 @@ function parseAddPackageOptions(args) {
312
314
  index += 1;
313
315
  continue;
314
316
  }
317
+ if (arg === "--link-from") {
318
+ const value = args[index + 1];
319
+ if (!value) {
320
+ throw new Error("--link-from requires a value");
321
+ }
322
+ linkFrom.push(value);
323
+ index += 1;
324
+ continue;
325
+ }
315
326
  throw new Error(`Unknown option: ${arg}`);
316
327
  }
317
328
  if (!preset) {
@@ -320,7 +331,7 @@ function parseAddPackageOptions(args) {
320
331
  if (!name) {
321
332
  throw new Error("add package requires --name");
322
333
  }
323
- return { preset, name, path: packagePath };
334
+ return { preset, name, path: packagePath, linkFrom };
324
335
  }
325
336
  async function main(args) {
326
337
  const command = args[0];
@@ -417,6 +428,7 @@ async function main(args) {
417
428
  preset: options.preset,
418
429
  name: options.name,
419
430
  path: options.path,
431
+ linkFrom: options.linkFrom,
420
432
  });
421
433
  console.log(`Added ${options.preset} package ${options.name}`);
422
434
  return;
@@ -1,4 +1,6 @@
1
1
  import * as v from "valibot";
2
+ import type { PackageAdditionSupport } from "./package-addition-support.js";
3
+ import type { PackageLinkIntent, PackageRole, PackageSourcePreset } from "./package-linking.js";
2
4
  export type BuiltInPreset = {
3
5
  name: string;
4
6
  title: string;
@@ -6,6 +8,7 @@ export type BuiltInPreset = {
6
8
  generation: "supported" | "future";
7
9
  supportedPackageManagers: readonly PackageManager[];
8
10
  supportedProjectKinds: readonly ProjectKind[];
11
+ packageAdditionSupport: PackageAdditionSupport;
9
12
  features: readonly FeatureName[];
10
13
  };
11
14
  export type PackageManager = "pnpm";
@@ -23,6 +26,8 @@ export type PresetFile = {
23
26
  export type ProjectPackage = {
24
27
  name: string;
25
28
  path: string;
29
+ role?: PackageRole;
30
+ sourcePreset?: PackageSourcePreset;
26
31
  };
27
32
  export type ProjectBlueprint = {
28
33
  schemaVersion: 1;
@@ -31,6 +36,7 @@ export type ProjectBlueprint = {
31
36
  projectKind: ProjectKind;
32
37
  features: FeatureName[];
33
38
  packages?: ProjectPackage[];
39
+ packageLinkIntents?: PackageLinkIntent[];
34
40
  };
35
41
  export declare const builtInPresets: readonly BuiltInPreset[];
36
42
  export declare const presetFileJsonSchema: {
@@ -123,6 +129,30 @@ export declare const blueprintJsonSchema: {
123
129
  readonly type: "string";
124
130
  readonly minLength: 1;
125
131
  };
132
+ readonly role: {
133
+ readonly enum: readonly ["runtime-service", "shared-library"];
134
+ };
135
+ readonly sourcePreset: {
136
+ readonly enum: readonly ["hono-api", "ts-lib", "vue-app"];
137
+ };
138
+ };
139
+ };
140
+ };
141
+ readonly packageLinkIntents: {
142
+ readonly type: "array";
143
+ readonly items: {
144
+ readonly type: "object";
145
+ readonly additionalProperties: false;
146
+ readonly required: readonly ["consumerPackagePath", "providerPackagePath"];
147
+ readonly properties: {
148
+ readonly consumerPackagePath: {
149
+ readonly type: "string";
150
+ readonly minLength: 1;
151
+ };
152
+ readonly providerPackagePath: {
153
+ readonly type: "string";
154
+ readonly minLength: 1;
155
+ };
126
156
  };
127
157
  };
128
158
  };
@@ -146,6 +176,12 @@ export declare const projectBlueprintSchema: v.StrictObjectSchema<{
146
176
  readonly packages: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
147
177
  readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
148
178
  readonly path: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
179
+ readonly role: v.OptionalSchema<v.PicklistSchema<["runtime-service", "shared-library"], undefined>, undefined>;
180
+ readonly sourcePreset: v.OptionalSchema<v.PicklistSchema<["hono-api", "ts-lib", "vue-app"], undefined>, undefined>;
181
+ }, undefined>, undefined>, undefined>;
182
+ readonly packageLinkIntents: v.OptionalSchema<v.ArraySchema<v.StrictObjectSchema<{
183
+ readonly consumerPackagePath: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
184
+ readonly providerPackagePath: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>;
149
185
  }, undefined>, undefined>, undefined>;
150
186
  }, undefined>;
151
187
  export type ValidationIssue = {
@@ -78,6 +78,20 @@ export const blueprintJsonSchema = {
78
78
  properties: {
79
79
  name: { type: "string", minLength: 1 },
80
80
  path: { type: "string", minLength: 1 },
81
+ role: { enum: ["runtime-service", "shared-library"] },
82
+ sourcePreset: { enum: ["hono-api", "ts-lib", "vue-app"] },
83
+ },
84
+ },
85
+ },
86
+ packageLinkIntents: {
87
+ type: "array",
88
+ items: {
89
+ type: "object",
90
+ additionalProperties: false,
91
+ required: ["consumerPackagePath", "providerPackagePath"],
92
+ properties: {
93
+ consumerPackagePath: { type: "string", minLength: 1 },
94
+ providerPackagePath: { type: "string", minLength: 1 },
81
95
  },
82
96
  },
83
97
  },
@@ -90,6 +104,15 @@ const projectKindSchema = v.picklist([
90
104
  "multi-package",
91
105
  ]);
92
106
  const featureNameSchema = v.picklist(featureNames);
107
+ const packageRoleSchema = v.picklist([
108
+ "runtime-service",
109
+ "shared-library",
110
+ ]);
111
+ const packageSourcePresetSchema = v.picklist([
112
+ "hono-api",
113
+ "ts-lib",
114
+ "vue-app",
115
+ ]);
93
116
  export const presetFileSchema = v.strictObject({
94
117
  schemaVersion: v.literal(1),
95
118
  name: nonEmptyString,
@@ -108,6 +131,12 @@ export const projectBlueprintSchema = v.strictObject({
108
131
  packages: v.optional(v.array(v.strictObject({
109
132
  name: nonEmptyString,
110
133
  path: nonEmptyString,
134
+ role: v.optional(packageRoleSchema),
135
+ sourcePreset: v.optional(packageSourcePresetSchema),
136
+ }))),
137
+ packageLinkIntents: v.optional(v.array(v.strictObject({
138
+ consumerPackagePath: nonEmptyString,
139
+ providerPackagePath: nonEmptyString,
111
140
  }))),
112
141
  });
113
142
  function formatIssuePath(issue) {
@@ -7,7 +7,7 @@ export type WorkspaceOrchestrationOwner = {
7
7
  readonly path: ".";
8
8
  };
9
9
  export type ComponentOwner = PackageBoundaryOwner | WorkspaceOrchestrationOwner;
10
- export type CheckComponentKind = "typescript-typecheck" | "oxc-lint" | "oxc-format-check" | "build" | "unit-test" | "e2e-test" | "turbo-check" | "turbo-package-check" | "rustfmt-check" | "cargo-clippy" | "cargo-test";
10
+ export type CheckComponentKind = "typescript-typecheck" | "oxc-lint" | "oxc-format-check" | "build" | "unit-test" | "e2e-test" | "turbo-check" | "turbo-package-typecheck" | "turbo-package-build" | "turbo-package-test" | "turbo-package-e2e-test" | "turbo-package-check" | "rustfmt-check" | "cargo-clippy" | "cargo-test";
11
11
  export type FixComponentKind = "oxc-format-write" | "oxc-lint-fix" | "turbo-fix" | "turbo-package-fix" | "rustfmt-write";
12
12
  export type CheckEnvironmentNeed = {
13
13
  readonly kind: "playwright-browser-assets";
@@ -20,6 +20,14 @@ function renderCheckComponentCommand(component) {
20
20
  return "pnpm run test:e2e";
21
21
  case "turbo-check":
22
22
  return "turbo run check";
23
+ case "turbo-package-typecheck":
24
+ return `turbo run typecheck ${renderTurboPackageFilter(component.owner)}`;
25
+ case "turbo-package-build":
26
+ return `turbo run build ${renderTurboPackageFilter(component.owner)}`;
27
+ case "turbo-package-test":
28
+ return `turbo run test ${renderTurboPackageFilter(component.owner)}`;
29
+ case "turbo-package-e2e-test":
30
+ return `turbo run test:e2e ${renderTurboPackageFilter(component.owner)}`;
23
31
  case "turbo-package-check":
24
32
  return `turbo run check ${renderTurboPackageFilter(component.owner)}`;
25
33
  case "rustfmt-check":
@@ -51,8 +59,8 @@ export function renderFixCommand(plan) {
51
59
  return plan.components.map(renderFixComponentCommand).join(" && ");
52
60
  }
53
61
  export function renderPlaywrightBrowserInstallCommand(need) {
54
- if (need.owner.path === "apps/web") {
55
- return `pnpm --filter ./apps/web exec playwright install ${need.browser}`;
62
+ if (need.owner.kind === "package-boundary" && need.owner.path !== ".") {
63
+ return `pnpm --filter ./${need.owner.path} exec playwright install ${need.browser}`;
56
64
  }
57
65
  return `pnpm exec playwright install ${need.browser}`;
58
66
  }
@@ -0,0 +1,5 @@
1
+ export declare const PackageAdditionSupport: {
2
+ readonly Supported: "supported";
3
+ readonly Unsupported: "unsupported";
4
+ };
5
+ export type PackageAdditionSupport = (typeof PackageAdditionSupport)[keyof typeof PackageAdditionSupport];
@@ -0,0 +1,4 @@
1
+ export const PackageAdditionSupport = {
2
+ Supported: "supported",
3
+ Unsupported: "unsupported",
4
+ };
@@ -3,5 +3,6 @@ export type AddPackageOptions = {
3
3
  preset: string;
4
4
  name: string;
5
5
  path?: string;
6
+ linkFrom?: readonly string[];
6
7
  };
7
8
  export declare function addPackage(options: AddPackageOptions): Promise<void>;