@voxgig/sdkgen 3.4.7 → 3.5.0

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 (194) hide show
  1. package/bin/voxgig-sdkgen +78 -10
  2. package/dist/action/action.d.ts +5 -2
  3. package/dist/action/action.js +113 -6
  4. package/dist/action/action.js.map +1 -1
  5. package/dist/action/check.d.ts +15 -0
  6. package/dist/action/check.js +347 -0
  7. package/dist/action/check.js.map +1 -0
  8. package/dist/action/dispatch.d.ts +8 -0
  9. package/dist/action/dispatch.js +74 -0
  10. package/dist/action/dispatch.js.map +1 -0
  11. package/dist/action/docs.d.ts +4 -0
  12. package/dist/action/docs.js +236 -0
  13. package/dist/action/docs.js.map +1 -0
  14. package/dist/action/doctor.d.ts +5 -2
  15. package/dist/action/doctor.js +526 -74
  16. package/dist/action/doctor.js.map +1 -1
  17. package/dist/action/feature.js +96 -17
  18. package/dist/action/feature.js.map +1 -1
  19. package/dist/action/kind.d.ts +30 -0
  20. package/dist/action/kind.js +258 -0
  21. package/dist/action/kind.js.map +1 -0
  22. package/dist/action/package.d.ts +25 -0
  23. package/dist/action/package.js +852 -0
  24. package/dist/action/package.js.map +1 -0
  25. package/dist/action/resolve.d.ts +18 -0
  26. package/dist/action/resolve.js +280 -0
  27. package/dist/action/resolve.js.map +1 -0
  28. package/dist/action/target.d.ts +7 -1
  29. package/dist/action/target.js +240 -97
  30. package/dist/action/target.js.map +1 -1
  31. package/dist/cmp/Docs.d.ts +4 -0
  32. package/dist/cmp/Docs.js +98 -0
  33. package/dist/cmp/Docs.js.map +1 -0
  34. package/dist/cmp/ExternalDocs.d.ts +2 -0
  35. package/dist/cmp/ExternalDocs.js +43 -0
  36. package/dist/cmp/ExternalDocs.js.map +1 -0
  37. package/dist/helpers/definition.d.ts +5 -0
  38. package/dist/helpers/definition.js +72 -0
  39. package/dist/helpers/definition.js.map +1 -0
  40. package/dist/helpers/featureSource.d.ts +8 -2
  41. package/dist/helpers/featureSource.js +61 -12
  42. package/dist/helpers/featureSource.js.map +1 -1
  43. package/dist/helpers/junk.d.ts +11 -0
  44. package/dist/helpers/junk.js +149 -0
  45. package/dist/helpers/junk.js.map +1 -0
  46. package/dist/helpers/manifest.d.ts +50 -0
  47. package/dist/helpers/manifest.js +328 -0
  48. package/dist/helpers/manifest.js.map +1 -0
  49. package/dist/helpers/modelcheck.d.ts +22 -0
  50. package/dist/helpers/modelcheck.js +203 -0
  51. package/dist/helpers/modelcheck.js.map +1 -0
  52. package/dist/helpers/semver.d.ts +4 -0
  53. package/dist/helpers/semver.js +174 -0
  54. package/dist/helpers/semver.js.map +1 -0
  55. package/dist/helpers/shipped.d.ts +4 -0
  56. package/dist/helpers/shipped.js +36 -0
  57. package/dist/helpers/shipped.js.map +1 -0
  58. package/dist/helpers/stdrep.d.ts +9 -1
  59. package/dist/helpers/stdrep.js +22 -0
  60. package/dist/helpers/stdrep.js.map +1 -1
  61. package/dist/sdkgen.d.ts +15 -3
  62. package/dist/sdkgen.js +233 -67
  63. package/dist/sdkgen.js.map +1 -1
  64. package/dist/tsconfig.tsbuildinfo +1 -1
  65. package/dist/types.d.ts +10 -2
  66. package/dist/utility.js +17 -0
  67. package/dist/utility.js.map +1 -1
  68. package/model/sdkgen.aontu +69 -0
  69. package/package.json +3 -2
  70. package/project/.sdk/model/feature/audit.aontu +1 -0
  71. package/project/.sdk/model/feature/cache.aontu +1 -0
  72. package/project/.sdk/model/feature/clienttrack.aontu +1 -0
  73. package/project/.sdk/model/feature/debug.aontu +1 -0
  74. package/project/.sdk/model/feature/idempotency.aontu +1 -0
  75. package/project/.sdk/model/feature/log.aontu +1 -0
  76. package/project/.sdk/model/feature/metrics.aontu +1 -0
  77. package/project/.sdk/model/feature/netsim.aontu +1 -0
  78. package/project/.sdk/model/feature/paging.aontu +1 -0
  79. package/project/.sdk/model/feature/proxy.aontu +1 -0
  80. package/project/.sdk/model/feature/ratelimit.aontu +1 -0
  81. package/project/.sdk/model/feature/rbac.aontu +1 -0
  82. package/project/.sdk/model/feature/retry.aontu +1 -0
  83. package/project/.sdk/model/feature/streaming.aontu +1 -0
  84. package/project/.sdk/model/feature/telemetry.aontu +1 -0
  85. package/project/.sdk/model/feature/test.aontu +1 -0
  86. package/project/.sdk/model/feature/timeout.aontu +1 -0
  87. package/project/.sdk/model/target/c.aontu +1 -0
  88. package/project/.sdk/model/target/clojure.aontu +1 -0
  89. package/project/.sdk/model/target/cpp.aontu +1 -0
  90. package/project/.sdk/model/target/dart.aontu +1 -0
  91. package/project/.sdk/model/target/elixir.aontu +1 -0
  92. package/project/.sdk/model/target/go-cli.aontu +1 -0
  93. package/project/.sdk/model/target/go-mcp.aontu +1 -0
  94. package/project/.sdk/model/target/go.aontu +1 -0
  95. package/project/.sdk/model/target/haskell.aontu +1 -0
  96. package/project/.sdk/model/target/java.aontu +1 -0
  97. package/project/.sdk/model/target/js.aontu +1 -0
  98. package/project/.sdk/model/target/kotlin.aontu +1 -0
  99. package/project/.sdk/model/target/lean.aontu +1 -0
  100. package/project/.sdk/model/target/lua.aontu +1 -0
  101. package/project/.sdk/model/target/ocaml.aontu +1 -0
  102. package/project/.sdk/model/target/perl.aontu +1 -0
  103. package/project/.sdk/model/target/php.aontu +1 -0
  104. package/project/.sdk/model/target/py-data.aontu +1 -0
  105. package/project/.sdk/model/target/py.aontu +1 -0
  106. package/project/.sdk/model/target/rb.aontu +1 -0
  107. package/project/.sdk/model/target/rust.aontu +1 -0
  108. package/project/.sdk/model/target/scala.aontu +1 -0
  109. package/project/.sdk/model/target/seneca-provider.aontu +1 -0
  110. package/project/.sdk/model/target/zig.aontu +1 -0
  111. package/project/.sdk/src/cmp/c/Config_c.ts +44 -0
  112. package/project/.sdk/src/cmp/c/fragment/Main.fragment.c +3 -1
  113. package/project/.sdk/src/cmp/clojure/Config_clojure.ts +37 -42
  114. package/project/.sdk/src/cmp/clojure/utility_clojure.ts +42 -0
  115. package/project/.sdk/src/cmp/cpp/Config_cpp.ts +18 -0
  116. package/project/.sdk/src/cmp/csharp/Config_csharp.ts +125 -52
  117. package/project/.sdk/src/cmp/csharp/fragment/Main.fragment.cs +3 -1
  118. package/project/.sdk/src/cmp/csharp/utility_csharp.ts +94 -6
  119. package/project/.sdk/src/cmp/dart/Config_dart.ts +43 -5
  120. package/project/.sdk/src/cmp/dart/fragment/Config.data.fragment.dart +74 -0
  121. package/project/.sdk/src/cmp/dart/fragment/Config.fragment.dart +6 -9
  122. package/project/.sdk/src/cmp/dart/fragment/Main.fragment.dart +16 -5
  123. package/project/.sdk/src/cmp/dart/utility_dart.ts +18 -0
  124. package/project/.sdk/src/cmp/elixir/Config_elixir.ts +128 -13
  125. package/project/.sdk/src/cmp/elixir/fragment/Main.fragment.ex +3 -1
  126. package/project/.sdk/src/cmp/elixir/utility_elixir.ts +6 -0
  127. package/project/.sdk/src/cmp/haskell/Config_haskell.ts +35 -52
  128. package/project/.sdk/src/cmp/haskell/Package_haskell.ts +1 -0
  129. package/project/.sdk/src/cmp/haskell/Test_haskell.ts +1 -1
  130. package/project/.sdk/src/cmp/haskell/utility_haskell.ts +15 -5
  131. package/project/.sdk/src/cmp/java/Config_java.ts +21 -0
  132. package/project/.sdk/src/cmp/kotlin/Config_kotlin.ts +15 -0
  133. package/project/.sdk/src/cmp/ocaml/Config_ocaml.ts +42 -39
  134. package/project/.sdk/src/cmp/perl/Config_perl.ts +15 -0
  135. package/project/.sdk/src/cmp/perl/fragment/Main.fragment.pm +3 -1
  136. package/project/.sdk/src/cmp/rust/Config_rust.ts +44 -0
  137. package/project/.sdk/src/cmp/rust/fragment/Main.fragment.rs +4 -2
  138. package/project/.sdk/src/cmp/scala/Config_scala.ts +15 -0
  139. package/project/.sdk/src/cmp/swift/Config_swift.ts +17 -0
  140. package/project/.sdk/src/cmp/swift/fragment/Main.fragment.swift +3 -1
  141. package/project/.sdk/src/cmp/zig/Config_zig.ts +44 -0
  142. package/project/.sdk/src/cmp/zig/TestEntity_zig.ts +9 -2
  143. package/project/.sdk/src/cmp/zig/fragment/Main.fragment.zig +3 -1
  144. package/project/.sdk/tm/c/core/sdk.h +1 -0
  145. package/project/.sdk/tm/c/utility/make_options.c +5 -1
  146. package/project/.sdk/tm/clojure/src/sdk/core.clj +51 -3
  147. package/project/.sdk/tm/cpp/core/types.hpp +4 -1
  148. package/project/.sdk/tm/cpp/utility/pipeline.hpp +5 -1
  149. package/project/.sdk/tm/csharp/test/PipelineTest.cs +15 -0
  150. package/project/.sdk/tm/csharp/utility/MakeOptions.cs +67 -1
  151. package/project/.sdk/tm/dart/lib/utility/MakeOptionsUtility.dart +43 -0
  152. package/project/.sdk/tm/elixir/lib/projectname/utility.ex +58 -2
  153. package/project/.sdk/tm/haskell/{test/TestJson.hs → src/SdkJson.hs} +8 -4
  154. package/project/.sdk/tm/haskell/src/SdkRuntime.hs +55 -2
  155. package/project/.sdk/tm/haskell/test/Runner.hs +1 -1
  156. package/project/.sdk/tm/haskell/test/StructCorpus.hs +1 -1
  157. package/project/.sdk/tm/java/core/SdkClient.java +3 -1
  158. package/project/.sdk/tm/java/utility/MakeOptions.java +5 -1
  159. package/project/.sdk/tm/kotlin/core/SdkClient.kt +3 -1
  160. package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +5 -1
  161. package/project/.sdk/tm/ocaml/Makefile +3 -2
  162. package/project/.sdk/tm/ocaml/sdk_json.ml +106 -0
  163. package/project/.sdk/tm/ocaml/sdk_runtime.ml +56 -0
  164. package/project/.sdk/tm/ocaml/test/struct_corpus.ml +4 -86
  165. package/project/.sdk/tm/perl/utility/make_options.pm +5 -1
  166. package/project/.sdk/tm/rust/utility/make_options.rs +79 -1
  167. package/project/.sdk/tm/scala/core/SdkClient.scala +3 -1
  168. package/project/.sdk/tm/scala/utility/Make.scala +5 -1
  169. package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +5 -1
  170. package/project/.sdk/tm/zig/core/utility.zig +85 -1
  171. package/project/sdkgen-package.json +57 -0
  172. package/src/action/action.ts +136 -6
  173. package/src/action/check.ts +495 -0
  174. package/src/action/dispatch.ts +105 -0
  175. package/src/action/docs.ts +310 -0
  176. package/src/action/doctor.ts +692 -81
  177. package/src/action/feature.ts +109 -17
  178. package/src/action/kind.ts +375 -0
  179. package/src/action/package.ts +1173 -0
  180. package/src/action/resolve.ts +362 -0
  181. package/src/action/target.ts +290 -108
  182. package/src/cmp/Docs.ts +125 -0
  183. package/src/cmp/ExternalDocs.ts +54 -0
  184. package/src/helpers/definition.ts +82 -0
  185. package/src/helpers/featureSource.ts +83 -13
  186. package/src/helpers/junk.ts +168 -0
  187. package/src/helpers/manifest.ts +474 -0
  188. package/src/helpers/modelcheck.ts +262 -0
  189. package/src/helpers/semver.ts +211 -0
  190. package/src/helpers/shipped.ts +41 -0
  191. package/src/helpers/stdrep.ts +70 -0
  192. package/src/sdkgen.ts +294 -66
  193. package/src/types.ts +33 -3
  194. package/src/utility.ts +17 -0
package/bin/voxgig-sdkgen CHANGED
@@ -4,11 +4,11 @@ const Path = require('node:path')
4
4
  const { statSync } = require('node:fs')
5
5
  const { parseArgs } = require('node:util')
6
6
 
7
- const { Shape, One } = require('shape')
7
+ const { Shape, One, Skip } = require('shape')
8
8
 
9
9
  const { SdkGen } = require('../dist/sdkgen.js')
10
10
 
11
- const VERSION = '3.0.0'
11
+ const VERSION = '3.5.0'
12
12
  const KONSOLE = console
13
13
 
14
14
 
@@ -59,18 +59,29 @@ async function operate(options) {
59
59
  dryrun: options.dryrun,
60
60
  })
61
61
 
62
- const res = await sdkgen.action(options.args)
62
+ const res = await sdkgen.action(options.args, {
63
+ only: options.only,
64
+ alias: options.alias,
65
+ force: options.force,
66
+ nofetch: options.nofetch,
67
+ })
63
68
 
64
- // `doctor` is a CHECK: it must fail the process so CI can gate on it.
65
- // Everything else reports success by not throwing.
69
+ // A CHECKING verb (`doctor`, `package check`) must fail the process so CI
70
+ // can gate on it. Everything else reports success by not throwing.
71
+ //
72
+ // The verb supplies its own `summary` where it has one, because only the
73
+ // verb knows what its findings mean; `doctor` predates that field and its
74
+ // wording is kept here rather than moved for the sake of moving it.
66
75
  if (res && res.report && false === res.report.ok) {
67
76
  const r = res.report
68
- KONSOLE.log(
69
- `\n.sdk has drifted from the scaffold: ` +
77
+
78
+ KONSOLE.log('\n' + (null == r.summary ?
79
+ `.sdk has drifted from the scaffold: ` +
70
80
  `${r.forked.length} forked, ${r.edited.length} edited, ` +
71
81
  `${r.stale.length} stale, ${r.missing.length} missing. ` +
72
82
  `Run \`voxgig-sdkgen target add <lang>\` to resync, ` +
73
- `and move any project decision into .sdk/model/.`)
83
+ `and move any project decision into .sdk/model/.` : r.summary))
84
+
74
85
  exit(new Error('sdk drift'))
75
86
  }
76
87
  }
@@ -103,6 +114,27 @@ function resolveOptions() {
103
114
  short: 'y',
104
115
  },
105
116
 
117
+ // PER-INVOCATION action arguments, not generator config — see the
118
+ // `flags` note in src/types.ts. They are routed through
119
+ // `sdkgen.action(args, flags)` rather than `SdkGen({…})`.
120
+ only: {
121
+ type: 'string',
122
+ },
123
+
124
+ alias: {
125
+ type: 'string',
126
+ },
127
+
128
+ force: {
129
+ type: 'boolean',
130
+ },
131
+
132
+ // `no-fetch`, not `fetch: false`: parseArgs has no negation, and the
133
+ // flag reads better at the call site as the exception it is.
134
+ 'no-fetch': {
135
+ type: 'boolean',
136
+ },
137
+
106
138
  }
107
139
  })
108
140
 
@@ -111,6 +143,10 @@ function resolveOptions() {
111
143
  help: !!args.values.help,
112
144
  version: !!args.values.version,
113
145
  dryrun: !!args.values.dryrun,
146
+ only: args.values.only,
147
+ alias: args.values.alias,
148
+ force: !!args.values.force,
149
+ nofetch: !!args.values['no-fetch'],
114
150
  args: args.positionals,
115
151
  }
116
152
 
@@ -119,11 +155,26 @@ function resolveOptions() {
119
155
 
120
156
 
121
157
  function validateOptions(rawOptions) {
158
+ // A CLOSED shape: a key not listed here is rejected, which is why every
159
+ // flag needs an entry in all three places (parse entry, this shape, the
160
+ // help text) rather than only the first.
122
161
  const optShape = Shape({
123
162
  debug: One(String, Boolean),
124
163
  help: Boolean,
125
164
  version: Boolean,
126
165
  dryrun: Boolean,
166
+ // `Skip`, not `One(String, undefined)`. An unlisted alternative is not
167
+ // how `shape` spells "may be absent": `One(String, undefined)` made the
168
+ // property REQUIRED, so every invocation without BOTH `--only` and
169
+ // `--alias` was rejected before it reached an action — which is every
170
+ // ordinary `target add`. `Optional(String)` is the other spelling and is
171
+ // wrong here for a subtler reason: it substitutes `''` for a missing
172
+ // value, and an EMPTY `--only` means "install nothing", which is
173
+ // deliberately not the same as not passing one.
174
+ only: Skip(String),
175
+ alias: Skip(String),
176
+ force: Boolean,
177
+ nofetch: Boolean,
127
178
  args: [String]
128
179
  })
129
180
 
@@ -152,17 +203,34 @@ function help() {
152
203
  return `Usage: voxgig-sdkgen [options] <action> [args...]
153
204
 
154
205
  Actions:
155
- target add <lang> Add (or resync) a language target
156
- feature add <name> Add a feature
206
+ target add <ref> Add (or resync) a language target
207
+ feature add <ref> Add a feature
208
+ docs add <ref> Add a docs item (a documentation destination)
209
+ package add <pkg> Add everything an sdkgen package provides
210
+ package check [path] Validate a package you are AUTHORING (default: .);
211
+ exits non-zero on any error finding
212
+ package list List installed items and the package each came from
213
+ package update <pkg> Fetch a newer version and refresh what it supplied
157
214
  doctor Report .sdk/ drift from the scaffold; exits non-zero
158
215
  when a component is forked, a template master edited,
159
216
  or a stale file left behind
160
217
 
218
+ A <ref> is a name (\`go\`), a package-relative path
219
+ (\`@acme/sdkgen-iot/iot-go\`) or an absolute path, optionally suffixed
220
+ \`~<alias>\` to install it under a different name.
221
+
161
222
  Options:
162
223
  -h, --help Show this help message
163
224
  -v, --version Show version
164
225
  -g, --debug <level> Debug level (default: info)
165
226
  -y, --dryrun Dry run (no changes written)
227
+ --only <items> package add: install only these, as
228
+ <kind>:<name>,... (default: everything provided)
229
+ --alias <map> package add: install under different names, as
230
+ <name>=<alias>,...
231
+ --force package update: overwrite locally-changed files
232
+ --no-fetch package update: skip the fetch and use the source
233
+ already installed
166
234
  `
167
235
  }
168
236
 
@@ -1,6 +1,9 @@
1
1
  import type { ActionContext } from '../types';
2
+ declare function hasIndexEntry(content: string, name: string): boolean;
2
3
  declare function appendIndexEntries(content: string, names: string[]): string;
4
+ declare function removeIndexEntries(content: string, names: string[]): string;
3
5
  declare const UpdateIndex: import("jostraca").Component;
4
6
  declare function parseAddNames(args: any[]): string[];
5
- declare function loadContent(actx: ActionContext, which: string | string[]): any;
6
- export { UpdateIndex, appendIndexEntries, parseAddNames, loadContent };
7
+ declare function loadContent(actx: ActionContext, which: string | string[], seed?: Record<string, string>): any;
8
+ declare function ensureModelInclude(actx: ActionContext, kind: string): boolean;
9
+ export { UpdateIndex, ensureModelInclude, appendIndexEntries, removeIndexEntries, hasIndexEntry, parseAddNames, loadContent };
@@ -4,24 +4,69 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.UpdateIndex = void 0;
7
+ exports.ensureModelInclude = ensureModelInclude;
7
8
  exports.appendIndexEntries = appendIndexEntries;
9
+ exports.removeIndexEntries = removeIndexEntries;
10
+ exports.hasIndexEntry = hasIndexEntry;
8
11
  exports.parseAddNames = parseAddNames;
9
12
  exports.loadContent = loadContent;
10
13
  const node_path_1 = __importDefault(require("node:path"));
11
14
  const jostraca_1 = require("jostraca");
15
+ const indexEntry = (name) => `@"${name}.aontu"`;
16
+ // An index line that is an ACTIVE include, and the name it includes — or
17
+ // undefined for a blank line, a comment, or anything else.
18
+ //
19
+ // Parsed rather than compared as a string, because both spellings around an
20
+ // include are legal aontu and mean opposite things:
21
+ //
22
+ // @"go.aontu" -> active, name 'go'
23
+ // @"go.aontu" # pinned -> active, name 'go' (trailing comment)
24
+ // @"go.aontu" -> active, name 'go' (indented)
25
+ // # @"go.aontu" -> NOT active
26
+ //
27
+ // A substring test (what this used to be) reads the commented-out form as
28
+ // present, so `target add go` on a project that had switched the target off
29
+ // by hand appended nothing and reported success while the target stayed
30
+ // absent from the model. A whole-line equality test fixes that but then
31
+ // misses the trailing-comment form, and appends a SECOND active include.
32
+ const INDEX_ENTRY_RE = /^\s*@"([^"]+)\.aontu"\s*(?:#.*)?$/;
33
+ function indexEntryName(line) {
34
+ const m = line.match(INDEX_ENTRY_RE);
35
+ return null == m ? undefined : m[1];
36
+ }
37
+ // Is this name already included by the index?
38
+ function hasIndexEntry(content, name) {
39
+ return content.split('\n')
40
+ .some((line) => indexEntryName(line) === name);
41
+ }
12
42
  // Append `@"<name>.aontu"` import lines for each name not already present in
13
43
  // the index content. Checking against the accumulating result (not the
14
44
  // original) means duplicate names in the same call are added at most once.
15
45
  function appendIndexEntries(content, names) {
16
46
  let out = content;
17
47
  for (const n of names) {
18
- const entry = `@"${n}.aontu"`;
19
- if (!out.includes(entry)) {
20
- out += '\n' + entry;
48
+ if (!hasIndexEntry(out, n)) {
49
+ out += '\n' + indexEntry(n);
21
50
  }
22
51
  }
23
52
  return out;
24
53
  }
54
+ // Drop the `@"<name>.aontu"` line for each name — the inverse of
55
+ // appendIndexEntries, matching line-exact for the same reasons.
56
+ //
57
+ // Nothing calls this yet: a `remove` action is the fast-follow this exists
58
+ // for (see docs/design/sdkgen-packages.md), and it is written here beside its
59
+ // inverse so the two cannot drift on how an entry is recognised.
60
+ function removeIndexEntries(content, names) {
61
+ const drop = new Set(names);
62
+ return content
63
+ .split('\n')
64
+ .filter((line) => {
65
+ const name = indexEntryName(line);
66
+ return undefined === name || !drop.has(name);
67
+ })
68
+ .join('\n');
69
+ }
25
70
  const UpdateIndex = (0, jostraca_1.cmp)(function UpdateIndex(props) {
26
71
  (0, jostraca_1.Content)(appendIndexEntries(props.content, props.names));
27
72
  });
@@ -35,16 +80,78 @@ function parseAddNames(args) {
35
80
  .flatMap((a) => 'string' === typeof a ? a.split(',') : a)
36
81
  .filter((n) => null != n && '' !== n);
37
82
  }
38
- function loadContent(actx, which) {
83
+ // The current index file for each kind, which `UpdateIndex` appends to.
84
+ //
85
+ // `seed` IS THE UPGRADE PATH. A project scaffolded before a kind existed has
86
+ // no `model/<kind>/<kind>-index.aontu` — every project alive today is in
87
+ // exactly that position for `docs` — and reading it unguarded made the FIRST
88
+ // `docs add` in any existing project fail on ENOENT before it wrote anything.
89
+ //
90
+ // Seeded per call rather than defaulted for every kind: a missing
91
+ // `target-index.aontu` in a scaffolded project is a broken project, and
92
+ // quietly recreating it would hide that. A kind the project has never used is
93
+ // a different thing, and only its own action knows which case it is in.
94
+ function loadContent(actx, which, seed) {
39
95
  which = Array.isArray(which) ? which : [which];
40
96
  const content = {};
41
97
  const fs = actx.fs();
42
98
  const modelfolder = node_path_1.default.dirname(actx.url);
43
99
  which.map((w) => {
44
100
  const indexfile = node_path_1.default.join(modelfolder, w, w + '-index.aontu');
45
- const indexcontent = fs.readFileSync(indexfile, 'utf8');
46
- content[`${w}_index`] = indexcontent;
101
+ content[`${w}_index`] = (null != seed?.[w] && !fs.existsSync(indexfile)) ?
102
+ seed[w] : fs.readFileSync(indexfile, 'utf8');
47
103
  });
48
104
  return content;
49
105
  }
106
+ // ENSURE THE PROJECT'S OWN MODEL INCLUDES A KIND'S INDEX.
107
+ //
108
+ // `model/sdk.aontu` is written once, by create-sdkgen, and includes the
109
+ // indexes of the kinds that existed then. So a project scaffolded before a
110
+ // kind existed — which is every project alive today, for `docs` — never
111
+ // includes its index, and the item's model file is an orphan: it is on disk,
112
+ // `<kind>-index.aontu` includes it, and NOTHING includes that. `main.kit.docs`
113
+ // is then absent from the compiled model, so `package list`, `package update`
114
+ // and `doctor` cannot see the item at all.
115
+ //
116
+ // Appending one include line is additive and idempotent, and it is the only
117
+ // way an existing project can adopt a new kind without hand-editing. The
118
+ // entry is parsed, not substring-matched, for the reason `hasIndexEntry`
119
+ // documents: a commented-out include means the project switched it OFF, and
120
+ // re-adding it would override that.
121
+ function ensureModelInclude(actx, kind) {
122
+ const fs = actx.fs();
123
+ const url = actx.url;
124
+ if (!fs.existsSync(url)) {
125
+ // Said out loud rather than skipped silently: without the include the
126
+ // item is invisible to the next model compile, and a quiet no-op here
127
+ // would look exactly like success.
128
+ actx.log.warn({
129
+ point: 'model-include-absent', kind, file: url,
130
+ note: url + ' not found, so ' + indexEntry(kind + '/' + kind + '-index') +
131
+ ' could not be added — add it by hand, or nothing will see any ' +
132
+ kind + ' item'
133
+ });
134
+ return false;
135
+ }
136
+ const name = kind + '/' + kind + '-index';
137
+ const content = String(fs.readFileSync(url, 'utf8'));
138
+ if (hasIndexEntry(content, name)) {
139
+ return false;
140
+ }
141
+ if (actx.opts?.dryrun) {
142
+ actx.log.info({
143
+ point: 'model-include-dryrun', kind, file: url, entry: indexEntry(name),
144
+ note: '** DRY RUN ** would add ' + indexEntry(name) + ' to ' + url
145
+ });
146
+ return false;
147
+ }
148
+ fs.writeFileSync(url, content + (content.endsWith('\n') ? '' : '\n') +
149
+ indexEntry(name) + '\n');
150
+ actx.log.info({
151
+ point: 'model-include-added', kind, file: url, entry: indexEntry(name),
152
+ note: url + ': added ' + indexEntry(name) +
153
+ ' — without it the project model never sees any ' + kind + ' item'
154
+ });
155
+ return true;
156
+ }
50
157
  //# sourceMappingURL=action.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/action/action.ts"],"names":[],"mappings":";;;;;;QAoEE,kBAAkB;QAClB,aAAa;QACb,WAAW;AArEb,0DAA4B;AAE5B,uCAGiB;AAQjB,6EAA6E;AAC7E,uEAAuE;AACvE,2EAA2E;AAC3E,SAAS,kBAAkB,CAAC,OAAe,EAAE,KAAe;IAC1D,IAAI,GAAG,GAAG,OAAO,CAAA;IAEjB,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAA;QAC7B,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,GAAG,IAAI,IAAI,GAAG,KAAK,CAAA;QACrB,CAAC;I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AAE,CAAC,aAAa,CAAC,GAAG,EAClB,OAAO,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAC9C,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;IAE1B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;QACZ,KAAK,EAAE,qBAAqB,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC;QACtE,IAAI,EAAE,GAAG,GAAG,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC;YACvC,iDAAiD,GAAG,IAAI,GAAG,OAAO;KACrE,CAAC,CAAA;IAEF,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { ActionContext, ActionResult } from '../types';
2
+ import type { Finding } from '../helpers/manifest';
3
+ type CheckReport = {
4
+ ok: boolean;
5
+ ref: string;
6
+ root: string;
7
+ errors: number;
8
+ warnings: number;
9
+ findings: Finding[];
10
+ summary: string;
11
+ };
12
+ declare function cmd_package_check(args: string[], actx: ActionContext): Promise<ActionResult>;
13
+ declare function checkPackage(ref: string, actx: ActionContext): CheckReport;
14
+ export type { CheckReport, };
15
+ export { cmd_package_check, checkPackage, };