@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.
- package/bin/voxgig-sdkgen +78 -10
- package/dist/action/action.d.ts +5 -2
- package/dist/action/action.js +113 -6
- package/dist/action/action.js.map +1 -1
- package/dist/action/check.d.ts +15 -0
- package/dist/action/check.js +347 -0
- package/dist/action/check.js.map +1 -0
- package/dist/action/dispatch.d.ts +8 -0
- package/dist/action/dispatch.js +74 -0
- package/dist/action/dispatch.js.map +1 -0
- package/dist/action/docs.d.ts +4 -0
- package/dist/action/docs.js +236 -0
- package/dist/action/docs.js.map +1 -0
- package/dist/action/doctor.d.ts +5 -2
- package/dist/action/doctor.js +526 -74
- package/dist/action/doctor.js.map +1 -1
- package/dist/action/feature.js +96 -17
- package/dist/action/feature.js.map +1 -1
- package/dist/action/kind.d.ts +30 -0
- package/dist/action/kind.js +258 -0
- package/dist/action/kind.js.map +1 -0
- package/dist/action/package.d.ts +25 -0
- package/dist/action/package.js +852 -0
- package/dist/action/package.js.map +1 -0
- package/dist/action/resolve.d.ts +18 -0
- package/dist/action/resolve.js +280 -0
- package/dist/action/resolve.js.map +1 -0
- package/dist/action/target.d.ts +7 -1
- package/dist/action/target.js +240 -97
- package/dist/action/target.js.map +1 -1
- package/dist/cmp/Docs.d.ts +4 -0
- package/dist/cmp/Docs.js +98 -0
- package/dist/cmp/Docs.js.map +1 -0
- package/dist/cmp/ExternalDocs.d.ts +2 -0
- package/dist/cmp/ExternalDocs.js +43 -0
- package/dist/cmp/ExternalDocs.js.map +1 -0
- package/dist/helpers/definition.d.ts +5 -0
- package/dist/helpers/definition.js +72 -0
- package/dist/helpers/definition.js.map +1 -0
- package/dist/helpers/featureSource.d.ts +8 -2
- package/dist/helpers/featureSource.js +61 -12
- package/dist/helpers/featureSource.js.map +1 -1
- package/dist/helpers/junk.d.ts +11 -0
- package/dist/helpers/junk.js +149 -0
- package/dist/helpers/junk.js.map +1 -0
- package/dist/helpers/manifest.d.ts +50 -0
- package/dist/helpers/manifest.js +328 -0
- package/dist/helpers/manifest.js.map +1 -0
- package/dist/helpers/modelcheck.d.ts +22 -0
- package/dist/helpers/modelcheck.js +203 -0
- package/dist/helpers/modelcheck.js.map +1 -0
- package/dist/helpers/semver.d.ts +4 -0
- package/dist/helpers/semver.js +174 -0
- package/dist/helpers/semver.js.map +1 -0
- package/dist/helpers/shipped.d.ts +4 -0
- package/dist/helpers/shipped.js +36 -0
- package/dist/helpers/shipped.js.map +1 -0
- package/dist/helpers/stdrep.d.ts +9 -1
- package/dist/helpers/stdrep.js +22 -0
- package/dist/helpers/stdrep.js.map +1 -1
- package/dist/sdkgen.d.ts +15 -3
- package/dist/sdkgen.js +233 -67
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +10 -2
- package/dist/utility.js +17 -0
- package/dist/utility.js.map +1 -1
- package/model/sdkgen.aontu +69 -0
- package/package.json +3 -2
- package/project/.sdk/model/feature/audit.aontu +1 -0
- package/project/.sdk/model/feature/cache.aontu +1 -0
- package/project/.sdk/model/feature/clienttrack.aontu +1 -0
- package/project/.sdk/model/feature/debug.aontu +1 -0
- package/project/.sdk/model/feature/idempotency.aontu +1 -0
- package/project/.sdk/model/feature/log.aontu +1 -0
- package/project/.sdk/model/feature/metrics.aontu +1 -0
- package/project/.sdk/model/feature/netsim.aontu +1 -0
- package/project/.sdk/model/feature/paging.aontu +1 -0
- package/project/.sdk/model/feature/proxy.aontu +1 -0
- package/project/.sdk/model/feature/ratelimit.aontu +1 -0
- package/project/.sdk/model/feature/rbac.aontu +1 -0
- package/project/.sdk/model/feature/retry.aontu +1 -0
- package/project/.sdk/model/feature/streaming.aontu +1 -0
- package/project/.sdk/model/feature/telemetry.aontu +1 -0
- package/project/.sdk/model/feature/test.aontu +1 -0
- package/project/.sdk/model/feature/timeout.aontu +1 -0
- package/project/.sdk/model/target/c.aontu +1 -0
- package/project/.sdk/model/target/clojure.aontu +1 -0
- package/project/.sdk/model/target/cpp.aontu +1 -0
- package/project/.sdk/model/target/dart.aontu +1 -0
- package/project/.sdk/model/target/elixir.aontu +1 -0
- package/project/.sdk/model/target/go-cli.aontu +1 -0
- package/project/.sdk/model/target/go-mcp.aontu +1 -0
- package/project/.sdk/model/target/go.aontu +1 -0
- package/project/.sdk/model/target/haskell.aontu +1 -0
- package/project/.sdk/model/target/java.aontu +1 -0
- package/project/.sdk/model/target/js.aontu +1 -0
- package/project/.sdk/model/target/kotlin.aontu +1 -0
- package/project/.sdk/model/target/lean.aontu +1 -0
- package/project/.sdk/model/target/lua.aontu +1 -0
- package/project/.sdk/model/target/ocaml.aontu +1 -0
- package/project/.sdk/model/target/perl.aontu +1 -0
- package/project/.sdk/model/target/php.aontu +1 -0
- package/project/.sdk/model/target/py-data.aontu +1 -0
- package/project/.sdk/model/target/py.aontu +1 -0
- package/project/.sdk/model/target/rb.aontu +1 -0
- package/project/.sdk/model/target/rust.aontu +1 -0
- package/project/.sdk/model/target/scala.aontu +1 -0
- package/project/.sdk/model/target/seneca-provider.aontu +1 -0
- package/project/.sdk/model/target/zig.aontu +1 -0
- package/project/.sdk/src/cmp/c/Config_c.ts +44 -0
- package/project/.sdk/src/cmp/c/fragment/Main.fragment.c +3 -1
- package/project/.sdk/src/cmp/clojure/Config_clojure.ts +37 -42
- package/project/.sdk/src/cmp/clojure/utility_clojure.ts +42 -0
- package/project/.sdk/src/cmp/cpp/Config_cpp.ts +18 -0
- package/project/.sdk/src/cmp/csharp/Config_csharp.ts +125 -52
- package/project/.sdk/src/cmp/csharp/fragment/Main.fragment.cs +3 -1
- package/project/.sdk/src/cmp/csharp/utility_csharp.ts +94 -6
- package/project/.sdk/src/cmp/dart/Config_dart.ts +43 -5
- package/project/.sdk/src/cmp/dart/fragment/Config.data.fragment.dart +74 -0
- package/project/.sdk/src/cmp/dart/fragment/Config.fragment.dart +6 -9
- package/project/.sdk/src/cmp/dart/fragment/Main.fragment.dart +16 -5
- package/project/.sdk/src/cmp/dart/utility_dart.ts +18 -0
- package/project/.sdk/src/cmp/elixir/Config_elixir.ts +128 -13
- package/project/.sdk/src/cmp/elixir/fragment/Main.fragment.ex +3 -1
- package/project/.sdk/src/cmp/elixir/utility_elixir.ts +6 -0
- package/project/.sdk/src/cmp/haskell/Config_haskell.ts +35 -52
- package/project/.sdk/src/cmp/haskell/Package_haskell.ts +1 -0
- package/project/.sdk/src/cmp/haskell/Test_haskell.ts +1 -1
- package/project/.sdk/src/cmp/haskell/utility_haskell.ts +15 -5
- package/project/.sdk/src/cmp/java/Config_java.ts +21 -0
- package/project/.sdk/src/cmp/kotlin/Config_kotlin.ts +15 -0
- package/project/.sdk/src/cmp/ocaml/Config_ocaml.ts +42 -39
- package/project/.sdk/src/cmp/perl/Config_perl.ts +15 -0
- package/project/.sdk/src/cmp/perl/fragment/Main.fragment.pm +3 -1
- package/project/.sdk/src/cmp/rust/Config_rust.ts +44 -0
- package/project/.sdk/src/cmp/rust/fragment/Main.fragment.rs +4 -2
- package/project/.sdk/src/cmp/scala/Config_scala.ts +15 -0
- package/project/.sdk/src/cmp/swift/Config_swift.ts +17 -0
- package/project/.sdk/src/cmp/swift/fragment/Main.fragment.swift +3 -1
- package/project/.sdk/src/cmp/zig/Config_zig.ts +44 -0
- package/project/.sdk/src/cmp/zig/TestEntity_zig.ts +9 -2
- package/project/.sdk/src/cmp/zig/fragment/Main.fragment.zig +3 -1
- package/project/.sdk/tm/c/core/sdk.h +1 -0
- package/project/.sdk/tm/c/utility/make_options.c +5 -1
- package/project/.sdk/tm/clojure/src/sdk/core.clj +51 -3
- package/project/.sdk/tm/cpp/core/types.hpp +4 -1
- package/project/.sdk/tm/cpp/utility/pipeline.hpp +5 -1
- package/project/.sdk/tm/csharp/test/PipelineTest.cs +15 -0
- package/project/.sdk/tm/csharp/utility/MakeOptions.cs +67 -1
- package/project/.sdk/tm/dart/lib/utility/MakeOptionsUtility.dart +43 -0
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +58 -2
- package/project/.sdk/tm/haskell/{test/TestJson.hs → src/SdkJson.hs} +8 -4
- package/project/.sdk/tm/haskell/src/SdkRuntime.hs +55 -2
- package/project/.sdk/tm/haskell/test/Runner.hs +1 -1
- package/project/.sdk/tm/haskell/test/StructCorpus.hs +1 -1
- package/project/.sdk/tm/java/core/SdkClient.java +3 -1
- package/project/.sdk/tm/java/utility/MakeOptions.java +5 -1
- package/project/.sdk/tm/kotlin/core/SdkClient.kt +3 -1
- package/project/.sdk/tm/kotlin/utility/MakeOptions.kt +5 -1
- package/project/.sdk/tm/ocaml/Makefile +3 -2
- package/project/.sdk/tm/ocaml/sdk_json.ml +106 -0
- package/project/.sdk/tm/ocaml/sdk_runtime.ml +56 -0
- package/project/.sdk/tm/ocaml/test/struct_corpus.ml +4 -86
- package/project/.sdk/tm/perl/utility/make_options.pm +5 -1
- package/project/.sdk/tm/rust/utility/make_options.rs +79 -1
- package/project/.sdk/tm/scala/core/SdkClient.scala +3 -1
- package/project/.sdk/tm/scala/utility/Make.scala +5 -1
- package/project/.sdk/tm/swift/Sources/ProjectNameSDK/utility/MakeOptions.swift +5 -1
- package/project/.sdk/tm/zig/core/utility.zig +85 -1
- package/project/sdkgen-package.json +57 -0
- package/src/action/action.ts +136 -6
- package/src/action/check.ts +495 -0
- package/src/action/dispatch.ts +105 -0
- package/src/action/docs.ts +310 -0
- package/src/action/doctor.ts +692 -81
- package/src/action/feature.ts +109 -17
- package/src/action/kind.ts +375 -0
- package/src/action/package.ts +1173 -0
- package/src/action/resolve.ts +362 -0
- package/src/action/target.ts +290 -108
- package/src/cmp/Docs.ts +125 -0
- package/src/cmp/ExternalDocs.ts +54 -0
- package/src/helpers/definition.ts +82 -0
- package/src/helpers/featureSource.ts +83 -13
- package/src/helpers/junk.ts +168 -0
- package/src/helpers/manifest.ts +474 -0
- package/src/helpers/modelcheck.ts +262 -0
- package/src/helpers/semver.ts +211 -0
- package/src/helpers/shipped.ts +41 -0
- package/src/helpers/stdrep.ts +70 -0
- package/src/sdkgen.ts +294 -66
- package/src/types.ts +33 -3
- 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.
|
|
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`
|
|
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
|
-
|
|
69
|
-
|
|
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 <
|
|
156
|
-
feature add <
|
|
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
|
|
package/dist/action/action.d.ts
CHANGED
|
@@ -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
|
-
|
|
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 };
|
package/dist/action/action.js
CHANGED
|
@@ -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
|
-
|
|
19
|
-
|
|
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
|
-
|
|
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
|
-
|
|
46
|
-
|
|
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":";;;;;;
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/action/action.ts"],"names":[],"mappings":";;;;;;QAmME,kBAAkB;QAClB,kBAAkB;QAClB,kBAAkB;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Z,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, };
|