@uns-kit/cli 2.0.24 → 2.0.25

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/index.js CHANGED
@@ -374,6 +374,21 @@ async function initGitRepository(targetDir) {
374
374
  return false;
375
375
  }
376
376
  }
377
+ function setPackageScript(scripts, name, command) {
378
+ if (scripts[name] === command) {
379
+ return false;
380
+ }
381
+ scripts[name] = command;
382
+ return true;
383
+ }
384
+ function ensureUnsReferenceScripts(scripts) {
385
+ let changed = false;
386
+ changed = setPackageScript(scripts, "generate-uns-dictionary", "node ./node_modules/@uns-kit/core/dist/tools/generate-uns-dictionary.js --input uns-dictionary.json --output src/uns/uns-dictionary.generated.ts") || changed;
387
+ changed = setPackageScript(scripts, "generate-uns-measurements", "node ./node_modules/@uns-kit/core/dist/tools/generate-uns-measurements.js --input uns-measurements.json --output src/uns/uns-measurements.generated.ts") || changed;
388
+ changed = setPackageScript(scripts, "generate-uns-reference", "node ./node_modules/@uns-kit/core/dist/tools/generate-uns-reference.js --dictionary uns-dictionary.json --dictionary-output src/uns/uns-dictionary.generated.ts --measurements uns-measurements.json --measurements-output src/uns/uns-measurements.generated.ts") || changed;
389
+ changed = setPackageScript(scripts, "sync-uns-schema", "node ./node_modules/@uns-kit/core/dist/tools/sync-uns-schema.js") || changed;
390
+ return changed;
391
+ }
377
392
  async function configureDevops(targetPath, options) {
378
393
  const targetDir = path.resolve(process.cwd(), targetPath ?? ".");
379
394
  await ensureGitRepository(targetDir);
@@ -762,6 +777,7 @@ async function configurePython(targetPath, options = {}) {
762
777
  });
763
778
  }
764
779
  async function configureUnsReference(targetPath, options = {}) {
780
+ const targetDir = path.resolve(process.cwd(), targetPath ?? ".");
765
781
  await configurePlugin({
766
782
  targetPath,
767
783
  templateName: "uns-dictionary",
@@ -774,6 +790,27 @@ async function configureUnsReference(targetPath, options = {}) {
774
790
  label: "UNS measurements (units)",
775
791
  overwrite: options.overwrite,
776
792
  });
793
+ const packagePath = path.join(targetDir, "package.json");
794
+ let pkgRaw;
795
+ try {
796
+ pkgRaw = await readFile(packagePath, "utf8");
797
+ }
798
+ catch (error) {
799
+ if (error.code === "ENOENT") {
800
+ throw new Error(`Could not find package.json in ${targetDir}`);
801
+ }
802
+ throw error;
803
+ }
804
+ const pkg = JSON.parse(pkgRaw);
805
+ const scripts = (pkg.scripts ??= {});
806
+ const pkgChanged = ensureUnsReferenceScripts(scripts);
807
+ if (pkgChanged) {
808
+ await writeFile(packagePath, JSON.stringify(pkg, null, 2) + "\n", "utf8");
809
+ console.log(" Updated package.json schema scripts.");
810
+ }
811
+ else {
812
+ console.log(" Existing package.json already contained schema scripts.");
813
+ }
777
814
  }
778
815
  const configureFeatureHandlers = {
779
816
  devops: configureDevops,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uns-kit/cli",
3
- "version": "2.0.24",
3
+ "version": "2.0.25",
4
4
  "description": "Command line scaffolding tool for UNS applications",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,13 +26,13 @@
26
26
  ],
27
27
  "dependencies": {
28
28
  "azure-devops-node-api": "^15.1.1",
29
- "@uns-kit/core": "2.0.24"
29
+ "@uns-kit/core": "2.0.25"
30
30
  },
31
31
  "unsKitPackages": {
32
- "@uns-kit/core": "2.0.24",
33
- "@uns-kit/api": "2.0.24",
34
- "@uns-kit/cron": "2.0.24",
35
- "@uns-kit/temporal": "2.0.23"
32
+ "@uns-kit/core": "2.0.25",
33
+ "@uns-kit/api": "2.0.25",
34
+ "@uns-kit/cron": "2.0.25",
35
+ "@uns-kit/temporal": "2.0.25"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "tsc -p tsconfig.build.json",
@@ -19,5 +19,6 @@ Pointers for AI/code-assist tools when working in this generated project.
19
19
  - `pnpm run generate-uns-dictionary` -> updates `src/uns/uns-dictionary.generated.ts`
20
20
  - `pnpm run generate-uns-measurements` -> updates `src/uns/uns-measurements.generated.ts`
21
21
  - `pnpm run generate-uns-reference` -> runs both
22
- - `pnpm run generate-uns-topics-tags` -> refreshes topic/tag unions (requires GraphQL connectivity)
22
+ - `pnpm run generate-uns-metadata` -> refreshes topic/tag unions (requires GraphQL connectivity)
23
23
  - `pnpm run generate-codegen` -> GraphQL codegen (after configure-codegen)
24
+ - `pnpm run sync-uns-schema -- --controller-url ... --token ...` -> pulls `uns-dictionary.json` + `uns-measurements.json` from the controller and regenerates local TS helpers
@@ -19,5 +19,6 @@ Pointers for AI/code-assist tools when working in this generated project.
19
19
  - `pnpm run generate-uns-dictionary` -> updates `src/uns/uns-dictionary.generated.ts`
20
20
  - `pnpm run generate-uns-measurements` -> updates `src/uns/uns-measurements.generated.ts`
21
21
  - `pnpm run generate-uns-reference` -> runs both
22
- - `pnpm run generate-uns-topics-tags` -> refreshes topic/tag unions (requires GraphQL connectivity)
22
+ - `pnpm run generate-uns-metadata` -> refreshes topic/tag unions (requires GraphQL connectivity)
23
23
  - `pnpm run generate-codegen` -> GraphQL codegen (after configure-codegen)
24
+ - `pnpm run sync-uns-schema -- --controller-url ... --token ...` -> pulls `uns-dictionary.json` + `uns-measurements.json` from the controller and regenerates local TS helpers
@@ -12,10 +12,11 @@ pnpm run build # emit dist/ output
12
12
  pnpm run start # run the compiled entrypoint
13
13
  pnpm run generate-config-schema # regenerate config.schema.json and AppConfig augmentations
14
14
  pnpm run generate-codegen # regenerate typed GraphQL operations (after configure-codegen)
15
- pnpm run generate-uns-topics-tags # rebuild UNS topics/tags from the live schema
15
+ pnpm run generate-uns-metadata # rebuild UNS topics/tags from the live schema
16
16
  pnpm run generate-uns-dictionary # generate typed object/attribute dictionary from uns-dictionary.json
17
17
  pnpm run generate-uns-measurements # generate typed measurement units from uns-measurements.json
18
18
  pnpm run generate-uns-reference # run both dictionary + measurements generators
19
+ pnpm run sync-uns-schema -- --controller-url http://localhost:3200 --token <admin-bearer-token> # pull dictionary + measurements from the controller
19
20
  ```
20
21
 
21
22
  ## Configuration
@@ -30,7 +31,8 @@ Update `config.json` with your broker, UNS URLs, and credentials. The generated
30
31
  - Run `uns-kit configure-devops` to add the Azure DevOps pull-request tooling.
31
32
  - Run `uns-kit configure-vscode` to copy workspace/launch configuration for VS Code.
32
33
  - Run `uns-kit configure-codegen` to scaffold GraphQL code generation and UNS refresh scripts.
33
- - Edit `uns-dictionary.json` (object types/attributes + descriptions) and run `pnpm run generate-uns-dictionary` to emit `src/uns/uns-dictionary.generated.ts` for IDE hints/metadata; publish calls will automatically fall back to these descriptions when you omit them.
34
+ - Run `pnpm run sync-uns-schema -- --controller-url ... --token ...` to pull `uns-dictionary.json` and `uns-measurements.json` from the controller export into this project, then regenerate the typed files automatically.
35
+ - If you want to curate local files manually, edit `uns-dictionary.json` (object types/attributes + descriptions) and run `pnpm run generate-uns-dictionary` to emit `src/uns/uns-dictionary.generated.ts` for IDE hints/metadata; publish calls will automatically fall back to these descriptions when you omit them.
34
36
  - Edit `uns-measurements.json` (units + descriptions) and run `pnpm run generate-uns-measurements` to emit `src/uns/uns-measurements.generated.ts` and feed measurement unit IntelliSense.
35
37
  - Run `uns-kit configure-api` / `configure-cron` / `configure-temporal` to pull in example stubs and install the matching UNS plugins (add `--overwrite` to refresh templates).
36
38
  - Run `uns-kit configure-python` to copy the Python gateway client template (examples, scripts, proto).
@@ -29,7 +29,10 @@
29
29
  "generate-config-schema": "node ./node_modules/@uns-kit/core/dist/tools/generate-config-schema.js",
30
30
  "generate-codegen": "graphql-code-generator --require dotenv/config --config codegen.ts",
31
31
  "generate-uns-metadata": "node ./node_modules/@uns-kit/core/dist/tools/refresh-uns.js",
32
- "generate-uns-measurements": "node ./node_modules/@uns-kit/core/dist/tools/generate-uns-measurements.js --input uns-measurements.json --output src/uns/uns-measurements.generated.ts"
32
+ "generate-uns-dictionary": "node ./node_modules/@uns-kit/core/dist/tools/generate-uns-dictionary.js --input uns-dictionary.json --output src/uns/uns-dictionary.generated.ts",
33
+ "generate-uns-measurements": "node ./node_modules/@uns-kit/core/dist/tools/generate-uns-measurements.js --input uns-measurements.json --output src/uns/uns-measurements.generated.ts",
34
+ "generate-uns-reference": "node ./node_modules/@uns-kit/core/dist/tools/generate-uns-reference.js --dictionary uns-dictionary.json --dictionary-output src/uns/uns-dictionary.generated.ts --measurements uns-measurements.json --measurements-output src/uns/uns-measurements.generated.ts",
35
+ "sync-uns-schema": "node ./node_modules/@uns-kit/core/dist/tools/sync-uns-schema.js"
33
36
  },
34
37
  "dependencies": {
35
38
  "@uns-kit/core": "__UNS_KIT_CORE_VERSION__",