@loomweaver/cli 0.14.2 → 0.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +3 -0
  2. package/dist/main.mjs +92 -55
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -17,6 +17,9 @@ the style pipeline, the build target, the entry stylesheet, the composition root
17
17
  the output needs, listing each line it added. Anywhere else it writes the files and names what is
18
18
  left to wire by hand.
19
19
 
20
+ A weaver's components are named with the selector prefix the Angular application declares in
21
+ `angular.json`, or `app` where it declares none; `--prefix` names another.
22
+
20
23
  It also validates what the platform parses defensively, which is where mistakes go unreported:
21
24
 
22
25
  ```bash
package/dist/main.mjs CHANGED
@@ -1129,6 +1129,45 @@ function i18nFile(weaver) {
1129
1129
  return JSON.stringify(i18nBundle(weaver), null, 2) + "\n";
1130
1130
  }
1131
1131
 
1132
+ // ../devkit/src/lib/scaffolds/scaffold-values.ts
1133
+ var NEUTRAL_PREFIX = "app";
1134
+ function stringValue(values, name) {
1135
+ const value = values[name];
1136
+ return typeof value === "string" ? value : void 0;
1137
+ }
1138
+ function booleanValue(values, name) {
1139
+ const value = values[name];
1140
+ return typeof value === "boolean" ? value : void 0;
1141
+ }
1142
+ var PLACEMENT_OPTIONS = [
1143
+ {
1144
+ name: "directory",
1145
+ type: "string",
1146
+ description: "Project root, relative to the workspace root.",
1147
+ workspaceOnly: true
1148
+ },
1149
+ {
1150
+ name: "tags",
1151
+ type: "string",
1152
+ description: "Comma-separated Nx tags for the project.",
1153
+ workspaceOnly: true
1154
+ },
1155
+ {
1156
+ name: "unitTestRunner",
1157
+ type: "string",
1158
+ description: "Test wiring to emit. 'vitest' uses @nx/angular:unit-test; 'none' emits no test target.",
1159
+ choices: ["vitest", "none"],
1160
+ default: "vitest",
1161
+ workspaceOnly: true
1162
+ }
1163
+ ];
1164
+ var APP_OPTION = {
1165
+ name: "app",
1166
+ type: "string",
1167
+ description: "Application to drop into. Inferred when the workspace has exactly one.",
1168
+ workspaceOnly: true
1169
+ };
1170
+
1132
1171
  // ../devkit/src/lib/validate/manifest.ts
1133
1172
  var KNOWN_CAPABILITIES = [
1134
1173
  "contributions",
@@ -1288,6 +1327,18 @@ function deriveCapabilities(features) {
1288
1327
  }
1289
1328
  return KNOWN_CAPABILITIES.filter((capability) => set.has(capability));
1290
1329
  }
1330
+ function resolvePrefix(prefix) {
1331
+ const trimmed = prefix?.trim();
1332
+ if (!trimmed) {
1333
+ return NEUTRAL_PREFIX;
1334
+ }
1335
+ if (!isKebabId(trimmed)) {
1336
+ throw new Error(
1337
+ `Selector prefix must be kebab-case (e.g. "acme"); got "${trimmed}".`
1338
+ );
1339
+ }
1340
+ return trimmed;
1341
+ }
1291
1342
  function resolveWeaverInput(input) {
1292
1343
  if (!isKebabId(input.id)) {
1293
1344
  throw new Error(
@@ -1303,7 +1354,7 @@ function resolveWeaverInput(input) {
1303
1354
  propertyName: toCamelCase(input.id),
1304
1355
  capabilities,
1305
1356
  features,
1306
- prefix: input.prefix?.trim() || "lw",
1357
+ prefix: resolvePrefix(input.prefix),
1307
1358
  importPath: input.importPath?.trim() || `@loomweaver/${input.id}-weaver`
1308
1359
  };
1309
1360
  }
@@ -1565,7 +1616,7 @@ function accessLine(weaver) {
1565
1616
  }
1566
1617
 
1567
1618
  // ../devkit/src/recipes/platform-version.ts
1568
- var PLATFORM_VERSION = "0.14.2";
1619
+ var PLATFORM_VERSION = "0.14.3";
1569
1620
 
1570
1621
  // ../devkit/src/recipes/readme-notes.ts
1571
1622
  var UNTAGGED_NOTE = [
@@ -3008,52 +3059,6 @@ var layout = {
3008
3059
  }
3009
3060
  };
3010
3061
 
3011
- // ../devkit/src/lib/scaffolds/scaffold-values.ts
3012
- function stringValue(values, name) {
3013
- const value = values[name];
3014
- return typeof value === "string" ? value : void 0;
3015
- }
3016
- function booleanValue(values, name) {
3017
- const value = values[name];
3018
- return typeof value === "boolean" ? value : void 0;
3019
- }
3020
- var PLACEMENT_OPTIONS = [
3021
- {
3022
- name: "directory",
3023
- type: "string",
3024
- description: "Project root, relative to the workspace root.",
3025
- workspaceOnly: true
3026
- },
3027
- {
3028
- name: "tags",
3029
- type: "string",
3030
- description: "Comma-separated Nx tags for the project.",
3031
- workspaceOnly: true
3032
- },
3033
- {
3034
- name: "prefix",
3035
- type: "string",
3036
- description: "Selector prefix for generated components and directives.",
3037
- default: "lw",
3038
- pattern: KEBAB_ID_PATTERN,
3039
- workspaceOnly: true
3040
- },
3041
- {
3042
- name: "unitTestRunner",
3043
- type: "string",
3044
- description: "Test wiring to emit. 'vitest' uses @nx/angular:unit-test; 'none' emits no test target.",
3045
- choices: ["vitest", "none"],
3046
- default: "vitest",
3047
- workspaceOnly: true
3048
- }
3049
- ];
3050
- var APP_OPTION = {
3051
- name: "app",
3052
- type: "string",
3053
- description: "Application to drop into. Inferred when the workspace has exactly one.",
3054
- workspaceOnly: true
3055
- };
3056
-
3057
3062
  // ../devkit/src/recipes/angular-distribution/scaffold.ts
3058
3063
  function distributionInput(values) {
3059
3064
  return {
@@ -3092,6 +3097,13 @@ var distributionScaffold = {
3092
3097
  description: "Compose into the application already at that path, replacing the bootstrap files this scaffold owns and merging its build targets. Without it an existing project is an error.",
3093
3098
  workspaceOnly: true
3094
3099
  },
3100
+ {
3101
+ name: "prefix",
3102
+ type: "string",
3103
+ description: "Selector prefix the application declares for its components, which a weaver generated into it takes. Defaults to 'app'.",
3104
+ pattern: KEBAB_ID_PATTERN,
3105
+ workspaceOnly: true
3106
+ },
3095
3107
  ...PLACEMENT_OPTIONS
3096
3108
  ],
3097
3109
  build: (values) => generate(angularDistribution, distributionInput(values)),
@@ -3255,6 +3267,12 @@ var weaverScaffold = {
3255
3267
  description: "Import path for the workspace alias. Defaults to the workspace scope plus the project name.",
3256
3268
  workspaceOnly: true
3257
3269
  },
3270
+ {
3271
+ name: "prefix",
3272
+ type: "string",
3273
+ description: "Selector prefix for the generated components: the one the application declares, as the prefix of its project in angular.json or project.json. Read from the workspace where it can be, else 'app'.",
3274
+ pattern: KEBAB_ID_PATTERN
3275
+ },
3258
3276
  APP_OPTION,
3259
3277
  ...PLACEMENT_OPTIONS
3260
3278
  ],
@@ -3986,7 +4004,8 @@ function buildProjects(config) {
3986
4004
  const projects = asObject2(asObject2(config)?.["projects"]) ?? {};
3987
4005
  return Object.entries(projects).filter(([, project]) => buildTargetIn(project) !== void 0).map(([name, project]) => ({
3988
4006
  name,
3989
- root: normaliseRoot(asObject2(project)?.["root"])
4007
+ root: normaliseRoot(asObject2(project)?.["root"]),
4008
+ prefix: declaredPrefix(asObject2(project)?.["prefix"])
3990
4009
  }));
3991
4010
  }
3992
4011
  function buildTargetOf(config, project) {
@@ -4015,6 +4034,9 @@ function buildTargetIn(project) {
4015
4034
  }
4016
4035
  return void 0;
4017
4036
  }
4037
+ function declaredPrefix(value) {
4038
+ return typeof value === "string" && value.trim() ? value.trim() : void 0;
4039
+ }
4018
4040
  function normaliseRoot(value) {
4019
4041
  return typeof value === "string" ? withoutTrailingSlashes(value.replace(/^\.?\/*/, "")) : "";
4020
4042
  }
@@ -4153,18 +4175,33 @@ function directoryFromOut(out) {
4153
4175
  }
4154
4176
  return below || ".";
4155
4177
  }
4178
+ function declaredPrefix2(out) {
4179
+ const target = resolve3(out ?? ".");
4180
+ const workspace = findWorkspace(target);
4181
+ if (workspace?.kind !== "angular") {
4182
+ return void 0;
4183
+ }
4184
+ try {
4185
+ return resolveBuildProject(workspace, target).prefix;
4186
+ } catch (error) {
4187
+ if (error instanceof WorkspaceError) {
4188
+ return void 0;
4189
+ }
4190
+ throw error;
4191
+ }
4192
+ }
4156
4193
  function scaffoldValues(scaffold2, args) {
4194
+ const flag = args.flags["out"];
4195
+ const out = typeof flag === "string" ? flag : void 0;
4157
4196
  const values = valuesFor(scaffold2, args);
4197
+ const readsPrefix = values["prefix"] === void 0 && portableOptions(scaffold2).some((option) => option.name === "prefix");
4158
4198
  const takesDirectory = scaffold2.options.some(
4159
4199
  (option) => option.name === "directory"
4160
4200
  );
4161
- if (!takesDirectory) {
4162
- return values;
4163
- }
4164
- const out = args.flags["out"];
4165
4201
  return {
4166
4202
  ...values,
4167
- directory: directoryFromOut(typeof out === "string" ? out : void 0)
4203
+ ...readsPrefix && { prefix: declaredPrefix2(out) },
4204
+ ...takesDirectory && { directory: directoryFromOut(out) }
4168
4205
  };
4169
4206
  }
4170
4207
 
@@ -5180,7 +5217,7 @@ function validateCatalogCommand(args, io) {
5180
5217
  }
5181
5218
 
5182
5219
  // src/lib/run.ts
5183
- var VERSION = "0.14.2";
5220
+ var VERSION = "0.14.3";
5184
5221
  var COMMANDS = /* @__PURE__ */ new Map([
5185
5222
  ["init", init],
5186
5223
  ["list", list],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomweaver/cli",
3
- "version": "0.14.2",
3
+ "version": "0.14.3",
4
4
  "description": "LoomWeaver: open-source plugin platform for Angular workbenches. The scaffolding CLI: generates weavers, distributions and integrations into any project, with no Nx workspace and no checkout required.",
5
5
  "keywords": [
6
6
  "loomweaver",