ddd-ts-kit 0.5.0 → 0.6.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/README.md +22 -1
- package/dist/check/alias/build-scripts.d.ts.map +1 -1
- package/dist/check/alias/build-scripts.js +3 -1
- package/dist/check/alias/build-scripts.js.map +1 -1
- package/dist/check/configuration/config-inspection.d.ts +2 -0
- package/dist/check/configuration/config-inspection.d.ts.map +1 -1
- package/dist/check/configuration/config-inspection.js +5 -1
- package/dist/check/configuration/config-inspection.js.map +1 -1
- package/dist/check/rules/config-valid.d.ts.map +1 -1
- package/dist/check/rules/config-valid.js +1 -0
- package/dist/check/rules/config-valid.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +2 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/sdk.d.ts +8 -0
- package/dist/commands/sdk.d.ts.map +1 -0
- package/dist/commands/sdk.js +82 -0
- package/dist/commands/sdk.js.map +1 -0
- package/dist/config/config.d.ts +9 -0
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/default-sdk-name.d.ts +3 -0
- package/dist/config/default-sdk-name.d.ts.map +1 -0
- package/dist/config/default-sdk-name.js +3 -0
- package/dist/config/default-sdk-name.js.map +1 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +2 -0
- package/dist/config/index.js.map +1 -1
- package/dist/config/parse-config.d.ts.map +1 -1
- package/dist/config/parse-config.js +2 -0
- package/dist/config/parse-config.js.map +1 -1
- package/dist/config/parse-sdk.d.ts +4 -0
- package/dist/config/parse-sdk.d.ts.map +1 -0
- package/dist/config/parse-sdk.js +12 -0
- package/dist/config/parse-sdk.js.map +1 -0
- package/dist/config/restack-config-text.d.ts +1 -1
- package/dist/config/restack-config-text.d.ts.map +1 -1
- package/dist/config/restack-config-text.js +5 -2
- package/dist/config/restack-config-text.js.map +1 -1
- package/dist/config/sdk-accesses.d.ts +3 -0
- package/dist/config/sdk-accesses.d.ts.map +1 -0
- package/dist/config/sdk-accesses.js +3 -0
- package/dist/config/sdk-accesses.js.map +1 -0
- package/dist/config/sdk-problems.d.ts +4 -0
- package/dist/config/sdk-problems.d.ts.map +1 -0
- package/dist/config/sdk-problems.js +55 -0
- package/dist/config/sdk-problems.js.map +1 -0
- package/dist/config/serialize-config.js +5 -2
- package/dist/config/serialize-config.js.map +1 -1
- package/dist/generate/kinds/declare-context-entries.d.ts.map +1 -1
- package/dist/generate/kinds/declare-context-entries.js +3 -1
- package/dist/generate/kinds/declare-context-entries.js.map +1 -1
- package/dist/generate/kinds/extraction/entry-point.d.ts.map +1 -1
- package/dist/generate/kinds/extraction/entry-point.js +3 -1
- package/dist/generate/kinds/extraction/entry-point.js.map +1 -1
- package/dist/generate/kinds/knip-project.d.ts +7 -0
- package/dist/generate/kinds/knip-project.d.ts.map +1 -0
- package/dist/generate/kinds/knip-project.js +12 -0
- package/dist/generate/kinds/knip-project.js.map +1 -0
- package/dist/help/notes.d.ts +1 -1
- package/dist/help/notes.d.ts.map +1 -1
- package/dist/help/notes.js +6 -0
- package/dist/help/notes.js.map +1 -1
- package/dist/help/usage.d.ts +1 -1
- package/dist/help/usage.d.ts.map +1 -1
- package/dist/help/usage.js +2 -1
- package/dist/help/usage.js.map +1 -1
- package/dist/init/manifest/versions.js +23 -23
- package/dist/init/run-init.d.ts.map +1 -1
- package/dist/init/run-init.js +2 -0
- package/dist/init/run-init.js.map +1 -1
- package/dist/init/stack/resolve-stack.d.ts.map +1 -1
- package/dist/init/stack/resolve-stack.js +12 -2
- package/dist/init/stack/resolve-stack.js.map +1 -1
- package/dist/init/stack/stack-options.d.ts +2 -0
- package/dist/init/stack/stack-options.d.ts.map +1 -1
- package/dist/init/template-vars.d.ts.map +1 -1
- package/dist/init/template-vars.js +2 -0
- package/dist/init/template-vars.js.map +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +2 -0
- package/dist/run.js.map +1 -1
- package/dist/sdk/agent-instruction.d.ts +3 -0
- package/dist/sdk/agent-instruction.d.ts.map +1 -0
- package/dist/sdk/agent-instruction.js +3 -0
- package/dist/sdk/agent-instruction.js.map +1 -0
- package/dist/sdk/client-document.d.ts +16 -0
- package/dist/sdk/client-document.d.ts.map +1 -0
- package/dist/sdk/client-document.js +2 -0
- package/dist/sdk/client-document.js.map +1 -0
- package/dist/sdk/client-files.d.ts +7 -0
- package/dist/sdk/client-files.d.ts.map +1 -0
- package/dist/sdk/client-files.js +25 -0
- package/dist/sdk/client-files.js.map +1 -0
- package/dist/sdk/client-manifest.d.ts +14 -0
- package/dist/sdk/client-manifest.d.ts.map +1 -0
- package/dist/sdk/client-manifest.js +45 -0
- package/dist/sdk/client-manifest.js.map +1 -0
- package/dist/sdk/client-names.d.ts +7 -0
- package/dist/sdk/client-names.d.ts.map +1 -0
- package/dist/sdk/client-names.js +30 -0
- package/dist/sdk/client-names.js.map +1 -0
- package/dist/sdk/client-operation.d.ts +21 -0
- package/dist/sdk/client-operation.d.ts.map +1 -0
- package/dist/sdk/client-operation.js +2 -0
- package/dist/sdk/client-operation.js.map +1 -0
- package/dist/sdk/client-package-name.d.ts +3 -0
- package/dist/sdk/client-package-name.d.ts.map +1 -0
- package/dist/sdk/client-package-name.js +5 -0
- package/dist/sdk/client-package-name.js.map +1 -0
- package/dist/sdk/client-parameter.d.ts +9 -0
- package/dist/sdk/client-parameter.d.ts.map +1 -0
- package/dist/sdk/client-parameter.js +2 -0
- package/dist/sdk/client-parameter.js.map +1 -0
- package/dist/sdk/client-response.d.ts +10 -0
- package/dist/sdk/client-response.d.ts.map +1 -0
- package/dist/sdk/client-response.js +2 -0
- package/dist/sdk/client-response.js.map +1 -0
- package/dist/sdk/client-tsconfig.d.ts +7 -0
- package/dist/sdk/client-tsconfig.d.ts.map +1 -0
- package/dist/sdk/client-tsconfig.js +26 -0
- package/dist/sdk/client-tsconfig.js.map +1 -0
- package/dist/sdk/clients-directory.d.ts +3 -0
- package/dist/sdk/clients-directory.d.ts.map +1 -0
- package/dist/sdk/clients-directory.js +3 -0
- package/dist/sdk/clients-directory.js.map +1 -0
- package/dist/sdk/contract-documents.d.ts +11 -0
- package/dist/sdk/contract-documents.d.ts.map +1 -0
- package/dist/sdk/contract-documents.js +46 -0
- package/dist/sdk/contract-documents.js.map +1 -0
- package/dist/sdk/doc-comment.d.ts +3 -0
- package/dist/sdk/doc-comment.d.ts.map +1 -0
- package/dist/sdk/doc-comment.js +11 -0
- package/dist/sdk/doc-comment.js.map +1 -0
- package/dist/sdk/document-source.d.ts +6 -0
- package/dist/sdk/document-source.d.ts.map +1 -0
- package/dist/sdk/document-source.js +2 -0
- package/dist/sdk/document-source.js.map +1 -0
- package/dist/sdk/edit-json-file.d.ts +9 -0
- package/dist/sdk/edit-json-file.d.ts.map +1 -0
- package/dist/sdk/edit-json-file.js +31 -0
- package/dist/sdk/edit-json-file.js.map +1 -0
- package/dist/sdk/error-codes.d.ts +4 -0
- package/dist/sdk/error-codes.d.ts.map +1 -0
- package/dist/sdk/error-codes.js +6 -0
- package/dist/sdk/error-codes.js.map +1 -0
- package/dist/sdk/generated-header.d.ts +4 -0
- package/dist/sdk/generated-header.d.ts.map +1 -0
- package/dist/sdk/generated-header.js +5 -0
- package/dist/sdk/generated-header.js.map +1 -0
- package/dist/sdk/index.d.ts +3 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/index.js +3 -0
- package/dist/sdk/index.js.map +1 -0
- package/dist/sdk/instruct-agents.d.ts +8 -0
- package/dist/sdk/instruct-agents.d.ts.map +1 -0
- package/dist/sdk/instruct-agents.js +19 -0
- package/dist/sdk/instruct-agents.js.map +1 -0
- package/dist/sdk/is-input-optional.d.ts +4 -0
- package/dist/sdk/is-input-optional.d.ts.map +1 -0
- package/dist/sdk/is-input-optional.js +5 -0
- package/dist/sdk/is-input-optional.js.map +1 -0
- package/dist/sdk/is-json.d.ts +3 -0
- package/dist/sdk/is-json.d.ts.map +1 -0
- package/dist/sdk/is-json.js +5 -0
- package/dist/sdk/is-json.js.map +1 -0
- package/dist/sdk/manifest-json.d.ts +3 -0
- package/dist/sdk/manifest-json.d.ts.map +1 -0
- package/dist/sdk/manifest-json.js +5 -0
- package/dist/sdk/manifest-json.js.map +1 -0
- package/dist/sdk/operation-description.d.ts +4 -0
- package/dist/sdk/operation-description.d.ts.map +1 -0
- package/dist/sdk/operation-description.js +11 -0
- package/dist/sdk/operation-description.js.map +1 -0
- package/dist/sdk/operation-names.d.ts +8 -0
- package/dist/sdk/operation-names.d.ts.map +1 -0
- package/dist/sdk/operation-names.js +35 -0
- package/dist/sdk/operation-names.js.map +1 -0
- package/dist/sdk/operation-place.d.ts +8 -0
- package/dist/sdk/operation-place.d.ts.map +1 -0
- package/dist/sdk/operation-place.js +2 -0
- package/dist/sdk/operation-place.js.map +1 -0
- package/dist/sdk/planned-client.d.ts +8 -0
- package/dist/sdk/planned-client.d.ts.map +1 -0
- package/dist/sdk/planned-client.js +2 -0
- package/dist/sdk/planned-client.js.map +1 -0
- package/dist/sdk/planned-clients.d.ts +6 -0
- package/dist/sdk/planned-clients.d.ts.map +1 -0
- package/dist/sdk/planned-clients.js +30 -0
- package/dist/sdk/planned-clients.js.map +1 -0
- package/dist/sdk/property-key.d.ts +3 -0
- package/dist/sdk/property-key.d.ts.map +1 -0
- package/dist/sdk/property-key.js +6 -0
- package/dist/sdk/property-key.js.map +1 -0
- package/dist/sdk/put-file.d.ts +4 -0
- package/dist/sdk/put-file.d.ts.map +1 -0
- package/dist/sdk/put-file.js +10 -0
- package/dist/sdk/put-file.js.map +1 -0
- package/dist/sdk/read-client-document.d.ts +5 -0
- package/dist/sdk/read-client-document.d.ts.map +1 -0
- package/dist/sdk/read-client-document.js +34 -0
- package/dist/sdk/read-client-document.js.map +1 -0
- package/dist/sdk/read-operation.d.ts +4 -0
- package/dist/sdk/read-operation.d.ts.map +1 -0
- package/dist/sdk/read-operation.js +64 -0
- package/dist/sdk/read-operation.js.map +1 -0
- package/dist/sdk/read-responses.d.ts +4 -0
- package/dist/sdk/read-responses.d.ts.map +1 -0
- package/dist/sdk/read-responses.js +32 -0
- package/dist/sdk/read-responses.js.map +1 -0
- package/dist/sdk/read-schemes.d.ts +8 -0
- package/dist/sdk/read-schemes.d.ts.map +1 -0
- package/dist/sdk/read-schemes.js +37 -0
- package/dist/sdk/read-schemes.js.map +1 -0
- package/dist/sdk/read-security.d.ts +3 -0
- package/dist/sdk/read-security.d.ts.map +1 -0
- package/dist/sdk/read-security.js +7 -0
- package/dist/sdk/read-security.js.map +1 -0
- package/dist/sdk/render-client.d.ts +4 -0
- package/dist/sdk/render-client.d.ts.map +1 -0
- package/dist/sdk/render-client.js +49 -0
- package/dist/sdk/render-client.js.map +1 -0
- package/dist/sdk/render-errors.d.ts +4 -0
- package/dist/sdk/render-errors.d.ts.map +1 -0
- package/dist/sdk/render-errors.js +18 -0
- package/dist/sdk/render-errors.js.map +1 -0
- package/dist/sdk/render-index.d.ts +4 -0
- package/dist/sdk/render-index.d.ts.map +1 -0
- package/dist/sdk/render-index.js +22 -0
- package/dist/sdk/render-index.js.map +1 -0
- package/dist/sdk/render-input.d.ts +4 -0
- package/dist/sdk/render-input.d.ts.map +1 -0
- package/dist/sdk/render-input.js +31 -0
- package/dist/sdk/render-input.js.map +1 -0
- package/dist/sdk/render-operation.d.ts +7 -0
- package/dist/sdk/render-operation.d.ts.map +1 -0
- package/dist/sdk/render-operation.js +46 -0
- package/dist/sdk/render-operation.js.map +1 -0
- package/dist/sdk/render-operations.d.ts +4 -0
- package/dist/sdk/render-operations.d.ts.map +1 -0
- package/dist/sdk/render-operations.js +12 -0
- package/dist/sdk/render-operations.js.map +1 -0
- package/dist/sdk/render-readme.d.ts +9 -0
- package/dist/sdk/render-readme.d.ts.map +1 -0
- package/dist/sdk/render-readme.js +53 -0
- package/dist/sdk/render-readme.js.map +1 -0
- package/dist/sdk/render-result.d.ts +4 -0
- package/dist/sdk/render-result.d.ts.map +1 -0
- package/dist/sdk/render-result.js +26 -0
- package/dist/sdk/render-result.js.map +1 -0
- package/dist/sdk/render-schemas.d.ts +4 -0
- package/dist/sdk/render-schemas.d.ts.map +1 -0
- package/dist/sdk/render-schemas.js +15 -0
- package/dist/sdk/render-schemas.js.map +1 -0
- package/dist/sdk/schema-type-name.d.ts +3 -0
- package/dist/sdk/schema-type-name.d.ts.map +1 -0
- package/dist/sdk/schema-type-name.js +9 -0
- package/dist/sdk/schema-type-name.js.map +1 -0
- package/dist/sdk/schema-types.d.ts +17 -0
- package/dist/sdk/schema-types.d.ts.map +1 -0
- package/dist/sdk/schema-types.js +120 -0
- package/dist/sdk/schema-types.js.map +1 -0
- package/dist/sdk/scheme-carrier.d.ts +7 -0
- package/dist/sdk/scheme-carrier.d.ts.map +1 -0
- package/dist/sdk/scheme-carrier.js +2 -0
- package/dist/sdk/scheme-carrier.js.map +1 -0
- package/dist/sdk/sdk-scripts.d.ts +8 -0
- package/dist/sdk/sdk-scripts.d.ts.map +1 -0
- package/dist/sdk/sdk-scripts.js +26 -0
- package/dist/sdk/sdk-scripts.js.map +1 -0
- package/dist/sdk/sdk-set-up.d.ts +8 -0
- package/dist/sdk/sdk-set-up.d.ts.map +1 -0
- package/dist/sdk/sdk-set-up.js +2 -0
- package/dist/sdk/sdk-set-up.js.map +1 -0
- package/dist/sdk/set-up-sdk.d.ts +11 -0
- package/dist/sdk/set-up-sdk.d.ts.map +1 -0
- package/dist/sdk/set-up-sdk.js +19 -0
- package/dist/sdk/set-up-sdk.js.map +1 -0
- package/dist/sdk/type-name.d.ts +3 -0
- package/dist/sdk/type-name.d.ts.map +1 -0
- package/dist/sdk/type-name.js +5 -0
- package/dist/sdk/type-name.js.map +1 -0
- package/dist/sdk/unlocked-clients.d.ts +10 -0
- package/dist/sdk/unlocked-clients.d.ts.map +1 -0
- package/dist/sdk/unlocked-clients.js +36 -0
- package/dist/sdk/unlocked-clients.js.map +1 -0
- package/dist/sdk/wire-sdk.d.ts +12 -0
- package/dist/sdk/wire-sdk.d.ts.map +1 -0
- package/dist/sdk/wire-sdk.js +58 -0
- package/dist/sdk/wire-sdk.js.map +1 -0
- package/dist/sdk/with-client-paths.d.ts +8 -0
- package/dist/sdk/with-client-paths.d.ts.map +1 -0
- package/dist/sdk/with-client-paths.js +20 -0
- package/dist/sdk/with-client-paths.js.map +1 -0
- package/dist/sdk/with-entry.d.ts +3 -0
- package/dist/sdk/with-entry.d.ts.map +1 -0
- package/dist/sdk/with-entry.js +6 -0
- package/dist/sdk/with-entry.js.map +1 -0
- package/dist/sdk/with-knip-workspaces.d.ts +7 -0
- package/dist/sdk/with-knip-workspaces.d.ts.map +1 -0
- package/dist/sdk/with-knip-workspaces.js +40 -0
- package/dist/sdk/with-knip-workspaces.js.map +1 -0
- package/dist/sdk/write-clients.d.ts +10 -0
- package/dist/sdk/write-clients.d.ts.map +1 -0
- package/dist/sdk/write-clients.js +32 -0
- package/dist/sdk/write-clients.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/yaml/from-yaml.d.ts +8 -0
- package/dist/yaml/from-yaml.d.ts.map +1 -0
- package/dist/yaml/from-yaml.js +149 -0
- package/dist/yaml/from-yaml.js.map +1 -0
- package/dist/yaml/read-scalar.d.ts +7 -0
- package/dist/yaml/read-scalar.d.ts.map +1 -0
- package/dist/yaml/read-scalar.js +50 -0
- package/dist/yaml/read-scalar.js.map +1 -0
- package/dist/yaml/yaml-shape-error.d.ts +6 -0
- package/dist/yaml/yaml-shape-error.d.ts.map +1 -0
- package/dist/yaml/yaml-shape-error.js +10 -0
- package/dist/yaml/yaml-shape-error.js.map +1 -0
- package/package.json +2 -2
- package/templates/init/CLAUDE.md.tpl +3 -0
- package/templates/init/README.md.tpl +8 -1
- package/templates/init/rules/presentation.md.tpl +4 -1
- package/templates/pipeline/gitlab/gitlab-ci.yml.tpl +3 -0
- package/templates/pipeline/package-scripts.json +1 -1
- package/templates/sdk/errors.ts.tpl +30 -0
- package/templates/sdk/runtime.ts.tpl +347 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheme-carrier.js","sourceRoot":"","sources":["../../src/sdk/scheme-carrier.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The scripts of a project whose contract has clients: `sdk:generate` and `sdk:build`, the
|
|
3
|
+
* clients regenerated by `docs:generate` and compared by `docs:check` and `ci:docs`, and built by
|
|
4
|
+
* `ci:build`, the step the build job of the pipeline runs. A script the team already made run
|
|
5
|
+
* them is left as it is.
|
|
6
|
+
*/
|
|
7
|
+
export declare function sdkScripts(scripts: Readonly<Record<string, string>>): Record<string, string>;
|
|
8
|
+
//# sourceMappingURL=sdk-scripts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-scripts.d.ts","sourceRoot":"","sources":["../../src/sdk/sdk-scripts.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAiB5F"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** A script that already runs the generator or its check, whatever runs the CLI (`ddd-ts-kit`, a wrapper script). */
|
|
2
|
+
const RUNS_SDK = /\bsdk\b/;
|
|
3
|
+
const BUILD = 'node node_modules/@typescript/native/bin/tsc -b clients';
|
|
4
|
+
/**
|
|
5
|
+
* The scripts of a project whose contract has clients: `sdk:generate` and `sdk:build`, the
|
|
6
|
+
* clients regenerated by `docs:generate` and compared by `docs:check` and `ci:docs`, and built by
|
|
7
|
+
* `ci:build`, the step the build job of the pipeline runs. A script the team already made run
|
|
8
|
+
* them is left as it is.
|
|
9
|
+
*/
|
|
10
|
+
export function sdkScripts(scripts) {
|
|
11
|
+
const extended = (name, step, pattern = RUNS_SDK) => {
|
|
12
|
+
const script = scripts[name];
|
|
13
|
+
return script === undefined || pattern.test(script) ? {} : { [name]: `${script} && ${step}` };
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
...scripts,
|
|
17
|
+
'sdk:generate': scripts['sdk:generate'] ?? 'ddd-ts-kit sdk',
|
|
18
|
+
'sdk:build': scripts['sdk:build'] ?? BUILD,
|
|
19
|
+
...extended('docs:generate', 'ddd-ts-kit sdk'),
|
|
20
|
+
...extended('docs:check', 'ddd-ts-kit sdk --check'),
|
|
21
|
+
// A `ci:docs` that runs `docs:check` compares the clients through it.
|
|
22
|
+
...extended('ci:docs', 'ddd-ts-kit sdk --check', /\bsdk\b|docs:check/),
|
|
23
|
+
...extended('ci:build', 'npm run sdk:build', /\bsdk:build\b/),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=sdk-scripts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-scripts.js","sourceRoot":"","sources":["../../src/sdk/sdk-scripts.ts"],"names":[],"mappings":"AAAA,qHAAqH;AACrH,MAAM,QAAQ,GAAG,SAAS,CAAC;AAE3B,MAAM,KAAK,GAAG,yDAAyD,CAAC;AAExE;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,OAAyC;IAClE,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,OAAO,GAAG,QAAQ,EAA0B,EAAE;QAC1F,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAE7B,OAAO,MAAM,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,OAAO,IAAI,EAAE,EAAE,CAAC;IAChG,CAAC,CAAC;IAEF,OAAO;QACL,GAAG,OAAO;QACV,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC,IAAI,gBAAgB;QAC3D,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,IAAI,KAAK;QAC1C,GAAG,QAAQ,CAAC,eAAe,EAAE,gBAAgB,CAAC;QAC9C,GAAG,QAAQ,CAAC,YAAY,EAAE,wBAAwB,CAAC;QACnD,sEAAsE;QACtE,GAAG,QAAQ,CAAC,SAAS,EAAE,wBAAwB,EAAE,oBAAoB,CAAC;QACtE,GAAG,QAAQ,CAAC,UAAU,EAAE,mBAAmB,EAAE,eAAe,CAAC;KAC9D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** What setting up the clients leaves for someone to do. */
|
|
2
|
+
export interface SdkSetUp {
|
|
3
|
+
/** The directories of clients whose document the contract no longer has. */
|
|
4
|
+
readonly gone: readonly string[];
|
|
5
|
+
/** The directories of clients the npm lockfile does not link yet. */
|
|
6
|
+
readonly unlocked: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=sdk-set-up.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-set-up.d.ts","sourceRoot":"","sources":["../../src/sdk/sdk-set-up.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,MAAM,WAAW,QAAQ;IACvB,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,qEAAqE;IACrE,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk-set-up.js","sourceRoot":"","sources":["../../src/sdk/sdk-set-up.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Config } from '../config/index.js';
|
|
2
|
+
import type { Workspace } from '../workspace/index.js';
|
|
3
|
+
import type { SdkSetUp } from './sdk-set-up.js';
|
|
4
|
+
/**
|
|
5
|
+
* The clients of the contract and what the project needs around them, as "sdk" asks: what `init
|
|
6
|
+
* --sdk` writes in a new project and `ddd-ts-kit sdk` in any project, again at each change of the
|
|
7
|
+
* contract. Answers what is left to do, for the caller to say: the clients whose document is
|
|
8
|
+
* gone, and those the npm lockfile does not link yet.
|
|
9
|
+
*/
|
|
10
|
+
export declare function setUpSdk(ws: Workspace, config: Config): SdkSetUp;
|
|
11
|
+
//# sourceMappingURL=set-up-sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-up-sdk.d.ts","sourceRoot":"","sources":["../../src/sdk/set-up-sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAKhD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ,CAUhE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { plannedClients } from './planned-clients.js';
|
|
2
|
+
import { unlockedClients } from './unlocked-clients.js';
|
|
3
|
+
import { wireSdk } from './wire-sdk.js';
|
|
4
|
+
import { writeClients } from './write-clients.js';
|
|
5
|
+
/**
|
|
6
|
+
* The clients of the contract and what the project needs around them, as "sdk" asks: what `init
|
|
7
|
+
* --sdk` writes in a new project and `ddd-ts-kit sdk` in any project, again at each change of the
|
|
8
|
+
* contract. Answers what is left to do, for the caller to say: the clients whose document is
|
|
9
|
+
* gone, and those the npm lockfile does not link yet.
|
|
10
|
+
*/
|
|
11
|
+
export function setUpSdk(ws, config) {
|
|
12
|
+
if (config.sdk === undefined || config.stack.http === 'none') {
|
|
13
|
+
return { gone: [], unlocked: [] };
|
|
14
|
+
}
|
|
15
|
+
const clients = plannedClients(ws, config);
|
|
16
|
+
wireSdk(ws, config, clients);
|
|
17
|
+
return { gone: writeClients(ws, config, clients), unlocked: unlockedClients(ws, config, clients) };
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=set-up-sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-up-sdk.js","sourceRoot":"","sources":["../../src/sdk/set-up-sdk.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,EAAa,EAAE,MAAc;IACpD,IAAI,MAAM,CAAC,GAAG,KAAK,SAAS,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC7D,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IACpC,CAAC;IAED,MAAM,OAAO,GAAG,cAAc,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;IAE3C,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAE7B,OAAO,EAAE,IAAI,EAAE,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,eAAe,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;AACrG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-name.d.ts","sourceRoot":"","sources":["../../src/sdk/type-name.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,wBAAgB,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAErD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-name.js","sourceRoot":"","sources":["../../src/sdk/type-name.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,MAAM,UAAU,QAAQ,CAAC,YAAoB;IAC3C,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Config } from '../config/index.js';
|
|
2
|
+
import type { Workspace } from '../workspace/index.js';
|
|
3
|
+
import type { PlannedClient } from './planned-client.js';
|
|
4
|
+
/**
|
|
5
|
+
* The directories of the clients that the npm lockfile does not link yet: until `npm install`
|
|
6
|
+
* rewrites it, the frozen install of a pipeline (`npm ci`) refuses the lock. None under pnpm,
|
|
7
|
+
* whose frozen install accepts a new workspace package, nor in a project without a lockfile.
|
|
8
|
+
*/
|
|
9
|
+
export declare function unlockedClients(ws: Workspace, config: Config, clients: readonly PlannedClient[]): string[];
|
|
10
|
+
//# sourceMappingURL=unlocked-clients.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unlocked-clients.d.ts","sourceRoot":"","sources":["../../src/sdk/unlocked-clients.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKzD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,aAAa,EAAE,GAAG,MAAM,EAAE,CAgB1G"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { isRecord } from '../config/values/is-record.js';
|
|
2
|
+
/** The lockfile npm writes, which `npm ci` refuses while a workspace package is missing from it. */
|
|
3
|
+
const NPM_LOCKFILE = 'package-lock.json';
|
|
4
|
+
/**
|
|
5
|
+
* The directories of the clients that the npm lockfile does not link yet: until `npm install`
|
|
6
|
+
* rewrites it, the frozen install of a pipeline (`npm ci`) refuses the lock. None under pnpm,
|
|
7
|
+
* whose frozen install accepts a new workspace package, nor in a project without a lockfile.
|
|
8
|
+
*/
|
|
9
|
+
export function unlockedClients(ws, config, clients) {
|
|
10
|
+
const text = config.stack.packageManager === 'pnpm' ? undefined : ws.read(NPM_LOCKFILE);
|
|
11
|
+
if (text === undefined) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
const packages = lockedPackages(text);
|
|
15
|
+
if (packages === undefined) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
return clients
|
|
19
|
+
.filter(({ packageName, directory }) => !links(packages[`node_modules/${packageName}`], directory))
|
|
20
|
+
.map(({ directory }) => directory);
|
|
21
|
+
}
|
|
22
|
+
/** A lockfile that cannot be read is left to npm, which says it better. */
|
|
23
|
+
function lockedPackages(text) {
|
|
24
|
+
try {
|
|
25
|
+
const lock = JSON.parse(text);
|
|
26
|
+
const packages = isRecord(lock) ? lock['packages'] : undefined;
|
|
27
|
+
return isRecord(packages) ? packages : undefined;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function links(entry, directory) {
|
|
34
|
+
return isRecord(entry) && entry['link'] === true && entry['resolved'] === directory;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=unlocked-clients.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unlocked-clients.js","sourceRoot":"","sources":["../../src/sdk/unlocked-clients.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAIzD,oGAAoG;AACpG,MAAM,YAAY,GAAG,mBAAmB,CAAC;AAEzC;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,EAAa,EAAE,MAA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;AACtF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Config } from '../config/index.js';
|
|
2
|
+
import type { Workspace } from '../workspace/index.js';
|
|
3
|
+
import type { PlannedClient } from './planned-client.js';
|
|
4
|
+
/**
|
|
5
|
+
* What the project needs around its clients: each one a workspace package, resolved by its name
|
|
6
|
+
* from the sources (`paths` of tsconfig.json, which the type check, the test runner and knip
|
|
7
|
+
* read), left out of the formatter and of knip (whose config then names the root as a
|
|
8
|
+
* workspace of its own), which read generated code as written by hand,
|
|
9
|
+
* and the scripts that generate, compare and build them. Run again, it changes nothing.
|
|
10
|
+
*/
|
|
11
|
+
export declare function wireSdk(ws: Workspace, config: Config, clients: readonly PlannedClient[]): void;
|
|
12
|
+
//# sourceMappingURL=wire-sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire-sdk.d.ts","sourceRoot":"","sources":["../../src/sdk/wire-sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AASzD;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,aAAa,EAAE,GAAG,IAAI,CAc9F"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CLIENTS_DIRECTORY } from './clients-directory.js';
|
|
2
|
+
import { editJsonFile } from './edit-json-file.js';
|
|
3
|
+
import { sdkScripts } from './sdk-scripts.js';
|
|
4
|
+
import { withClientPaths } from './with-client-paths.js';
|
|
5
|
+
import { withEntry } from './with-entry.js';
|
|
6
|
+
import { withKnipWorkspaces } from './with-knip-workspaces.js';
|
|
7
|
+
const PACKAGES = `${CLIENTS_DIRECTORY}/*`;
|
|
8
|
+
const PNPM_WORKSPACE = 'pnpm-workspace.yaml';
|
|
9
|
+
/**
|
|
10
|
+
* What the project needs around its clients: each one a workspace package, resolved by its name
|
|
11
|
+
* from the sources (`paths` of tsconfig.json, which the type check, the test runner and knip
|
|
12
|
+
* read), left out of the formatter and of knip (whose config then names the root as a
|
|
13
|
+
* workspace of its own), which read generated code as written by hand,
|
|
14
|
+
* and the scripts that generate, compare and build them. Run again, it changes nothing.
|
|
15
|
+
*/
|
|
16
|
+
export function wireSdk(ws, config, clients) {
|
|
17
|
+
editJsonFile(ws, 'package.json', (manifest) => ({
|
|
18
|
+
...manifest,
|
|
19
|
+
...(config.stack.packageManager === 'pnpm' ? {} : { workspaces: withEntry(manifest['workspaces'], PACKAGES) }),
|
|
20
|
+
scripts: sdkScripts(texts(manifest['scripts'])),
|
|
21
|
+
}));
|
|
22
|
+
editJsonFile(ws, 'tsconfig.json', (tsconfig) => withClientPaths(tsconfig, clients));
|
|
23
|
+
editJsonFile(ws, 'biome.json', (biome) => withFormatterExclusion(biome));
|
|
24
|
+
editJsonFile(ws, 'knip.json', (knip) => withKnipWorkspaces(knip, PACKAGES));
|
|
25
|
+
if (config.stack.packageManager === 'pnpm') {
|
|
26
|
+
listInPnpmWorkspace(ws);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function texts(value) {
|
|
30
|
+
const entries = Object.entries(typeof value === 'object' && value !== null ? value : {});
|
|
31
|
+
return Object.fromEntries(entries.filter((entry) => typeof entry[1] === 'string'));
|
|
32
|
+
}
|
|
33
|
+
/** The sources of a client are written by the generator, as Biome would not: they are not formatted. */
|
|
34
|
+
function withFormatterExclusion(biome) {
|
|
35
|
+
const files = biome['files'];
|
|
36
|
+
if (typeof files !== 'object' || files === null || Array.isArray(files)) {
|
|
37
|
+
return biome;
|
|
38
|
+
}
|
|
39
|
+
const includes = Reflect.get(files, 'includes');
|
|
40
|
+
return { ...biome, files: { ...files, includes: withEntry(includes, `!**/${CLIENTS_DIRECTORY}/*/src`) } };
|
|
41
|
+
}
|
|
42
|
+
function listInPnpmWorkspace(ws) {
|
|
43
|
+
const text = ws.read(PNPM_WORKSPACE) ?? '';
|
|
44
|
+
if (/^packages:/m.test(text)) {
|
|
45
|
+
if (!text.includes(`'${PACKAGES}'`)) {
|
|
46
|
+
ws.note(`${PNPM_WORKSPACE} lists its own packages: add '${PACKAGES}' to them, so that each client is a package of the workspace.`);
|
|
47
|
+
}
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const content = `${text}${text === '' || text.endsWith('\n') ? '' : '\n'}# The clients of the contract, generated by \`ddd-ts-kit sdk\`.\npackages:\n - '${PACKAGES}'\n`;
|
|
51
|
+
if (ws.exists(PNPM_WORKSPACE)) {
|
|
52
|
+
ws.update(PNPM_WORKSPACE, content);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
ws.create(PNPM_WORKSPACE, content);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=wire-sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wire-sdk.js","sourceRoot":"","sources":["../../src/sdk/wire-sdk.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,QAAQ,GAAG,GAAG,iBAAiB,IAAI,CAAC;AAC1C,MAAM,cAAc,GAAG,qBAAqB,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,EAAa,EAAE,MAAc,EAAE,OAA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c,EAAE,OAAO,CAAC,CAAC;IACrC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PlannedClient } from './planned-client.js';
|
|
2
|
+
/**
|
|
3
|
+
* The compiler options with one `paths` entry per client, its package name resolved to its
|
|
4
|
+
* sources: a spec imports the client as a consumer would, and no build comes first. An entry
|
|
5
|
+
* of a client that is gone is removed; every other entry is kept.
|
|
6
|
+
*/
|
|
7
|
+
export declare function withClientPaths(tsconfig: Record<string, unknown>, clients: readonly PlannedClient[]): Record<string, unknown>;
|
|
8
|
+
//# sourceMappingURL=with-client-paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-client-paths.d.ts","sourceRoot":"","sources":["../../src/sdk/with-client-paths.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,OAAO,EAAE,SAAS,aAAa,EAAE,GAChC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAOzB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CLIENTS_DIRECTORY } from './clients-directory.js';
|
|
2
|
+
/**
|
|
3
|
+
* The compiler options with one `paths` entry per client, its package name resolved to its
|
|
4
|
+
* sources: a spec imports the client as a consumer would, and no build comes first. An entry
|
|
5
|
+
* of a client that is gone is removed; every other entry is kept.
|
|
6
|
+
*/
|
|
7
|
+
export function withClientPaths(tsconfig, clients) {
|
|
8
|
+
const options = record(tsconfig['compilerOptions']);
|
|
9
|
+
const paths = record(options['paths']);
|
|
10
|
+
const kept = Object.entries(paths).filter(([, targets]) => !pointsToClient(targets));
|
|
11
|
+
const own = clients.map((client) => [client.packageName, [`./${client.directory}/src/index.ts`]]);
|
|
12
|
+
return { ...tsconfig, compilerOptions: { ...options, paths: Object.fromEntries([...kept, ...own]) } };
|
|
13
|
+
}
|
|
14
|
+
function pointsToClient(targets) {
|
|
15
|
+
return Array.isArray(targets) && targets.some((target) => String(target).startsWith(`./${CLIENTS_DIRECTORY}/`));
|
|
16
|
+
}
|
|
17
|
+
function record(value) {
|
|
18
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value) ? { ...value } : {};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=with-client-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-client-paths.js","sourceRoot":"","sources":["../../src/sdk/with-client-paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAiC,EACjC,OAAiC;IAEjC,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACpD,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IACvC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IACrF,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,KAAK,MAAM,CAAC,SAAS,eAAe,CAAC,CAAU,CAAC,CAAC;IAE3G,OAAO,EAAE,GAAG,QAAQ,EAAE,eAAe,EAAE,EAAE,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC;AACxG,CAAC;AAED,SAAS,cAAc,CAAC,OAAgB;IACtC,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,KAAK,iBAAiB,GAAG,CAAC,CAAC,CAAC;AAClH,CAAC;AAED,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAClG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-entry.d.ts","sourceRoot":"","sources":["../../src/sdk/with-entry.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,EAAE,CAIlE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** A list of texts with one more entry, unless it holds it already; a value that is not a list becomes one. */
|
|
2
|
+
export function withEntry(value, entry) {
|
|
3
|
+
const list = Array.isArray(value) ? value : [];
|
|
4
|
+
return list.includes(entry) ? list : [...list, entry];
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=with-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-entry.js","sourceRoot":"","sources":["../../src/sdk/with-entry.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,MAAM,UAAU,SAAS,CAAC,KAAc,EAAE,KAAa;IACrD,MAAM,IAAI,GAAc,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAE1D,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* knip.json once the project has workspace packages: knip then reads the root as one workspace
|
|
3
|
+
* among others, so what the file said of the project (its entries, its files, the config of its
|
|
4
|
+
* plugins) moves under `workspaces["."]`, and the clients are left out, as generated code.
|
|
5
|
+
*/
|
|
6
|
+
export declare function withKnipWorkspaces(knip: Record<string, unknown>, packages: string): Record<string, unknown>;
|
|
7
|
+
//# sourceMappingURL=with-knip-workspaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-knip-workspaces.d.ts","sourceRoot":"","sources":["../../src/sdk/with-knip-workspaces.ts"],"names":[],"mappings":"AAqBA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAiB3G"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { withEntry } from './with-entry.js';
|
|
2
|
+
/** Keys of knip.json that apply to the whole repository, whatever the workspace. */
|
|
3
|
+
const ROOT_KEYS = new Set([
|
|
4
|
+
'$schema',
|
|
5
|
+
'workspaces',
|
|
6
|
+
'ignoreWorkspaces',
|
|
7
|
+
'ignoreDependencies',
|
|
8
|
+
'ignoreBinaries',
|
|
9
|
+
'ignoreUnresolved',
|
|
10
|
+
'ignoreMembers',
|
|
11
|
+
'ignoreExportsUsedInFile',
|
|
12
|
+
'includeEntryExports',
|
|
13
|
+
'ignoreIssues',
|
|
14
|
+
'rules',
|
|
15
|
+
'include',
|
|
16
|
+
'exclude',
|
|
17
|
+
'tags',
|
|
18
|
+
'treatConfigHintsAsErrors',
|
|
19
|
+
]);
|
|
20
|
+
/**
|
|
21
|
+
* knip.json once the project has workspace packages: knip then reads the root as one workspace
|
|
22
|
+
* among others, so what the file said of the project (its entries, its files, the config of its
|
|
23
|
+
* plugins) moves under `workspaces["."]`, and the clients are left out, as generated code.
|
|
24
|
+
*/
|
|
25
|
+
export function withKnipWorkspaces(knip, packages) {
|
|
26
|
+
const ignoreWorkspaces = withEntry(knip['ignoreWorkspaces'], packages);
|
|
27
|
+
if (knip['workspaces'] !== undefined) {
|
|
28
|
+
return { ...knip, ignoreWorkspaces };
|
|
29
|
+
}
|
|
30
|
+
const entries = Object.entries(knip);
|
|
31
|
+
const project = Object.fromEntries(entries.filter(([key]) => !ROOT_KEYS.has(key)));
|
|
32
|
+
const [schema, ...root] = entries.filter(([key]) => ROOT_KEYS.has(key) && key !== 'ignoreWorkspaces');
|
|
33
|
+
return {
|
|
34
|
+
...Object.fromEntries(schema === undefined ? [] : [schema]),
|
|
35
|
+
workspaces: { '.': project },
|
|
36
|
+
...Object.fromEntries(root),
|
|
37
|
+
ignoreWorkspaces,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=with-knip-workspaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-knip-workspaces.js","sourceRoot":"","sources":["../../src/sdk/with-knip-workspaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,oFAAoF;AACpF,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IACxB,SAAS;IACT,YAAY;IACZ,kBAAkB;IAClB,oBAAoB;IACpB,gBAAgB;IAChB,kBAAkB;IAClB,eAAe;IACf,yBAAyB;IACzB,qBAAqB;IACrB,cAAc;IACd,OAAO;IACP,SAAS;IACT,SAAS;IACT,MAAM;IACN,0BAA0B;CAC3B,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAA6B,EAAE,QAAgB;IAChF,MAAM,gBAAgB,GAAG,SAAS,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,QAAQ,CAAC,CAAC;IAEvE,IAAI,IAAI,CAAC,YAAY,CAAC,KAAK,SAAS,EAAE,CAAC;QACrC,OAAO,EAAE,GAAG,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACvC,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACnF,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,kBAAkB,CAAC,CAAC;IAEtG,OAAO;QACL,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAC3D,UAAU,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE;QAC5B,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;QAC3B,gBAAgB;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Config } from '../config/index.js';
|
|
2
|
+
import type { Workspace } from '../workspace/index.js';
|
|
3
|
+
import type { PlannedClient } from './planned-client.js';
|
|
4
|
+
/**
|
|
5
|
+
* Writes the client of every document of the contract, and the build config that compiles them
|
|
6
|
+
* all (`tsc -b clients`). A client whose document is gone is not deleted: it is answered, with
|
|
7
|
+
* its directory, for the command to say.
|
|
8
|
+
*/
|
|
9
|
+
export declare function writeClients(ws: Workspace, config: Config, clients: readonly PlannedClient[]): string[];
|
|
10
|
+
//# sourceMappingURL=write-clients.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-clients.d.ts","sourceRoot":"","sources":["../../src/sdk/write-clients.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,aAAa,EAAE,GAAG,MAAM,EAAE,CAmBvG"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { formatJson } from '../json/format-json.js';
|
|
2
|
+
import { clientFiles } from './client-files.js';
|
|
3
|
+
import { clientManifest } from './client-manifest.js';
|
|
4
|
+
import { CLIENTS_DIRECTORY } from './clients-directory.js';
|
|
5
|
+
import { putFile } from './put-file.js';
|
|
6
|
+
/**
|
|
7
|
+
* Writes the client of every document of the contract, and the build config that compiles them
|
|
8
|
+
* all (`tsc -b clients`). A client whose document is gone is not deleted: it is answered, with
|
|
9
|
+
* its directory, for the command to say.
|
|
10
|
+
*/
|
|
11
|
+
export function writeClients(ws, config, clients) {
|
|
12
|
+
for (const client of clients) {
|
|
13
|
+
writeClient(ws, config, client);
|
|
14
|
+
}
|
|
15
|
+
if (clients.length > 0) {
|
|
16
|
+
putFile(ws, `${CLIENTS_DIRECTORY}/tsconfig.json`, formatJson({ files: [], references: clients.map((client) => ({ path: `./${client.document.name}` })) }));
|
|
17
|
+
}
|
|
18
|
+
const names = new Set(clients.map((client) => client.document.name));
|
|
19
|
+
return ws
|
|
20
|
+
.directories(CLIENTS_DIRECTORY)
|
|
21
|
+
.filter((name) => !names.has(name) && ws.exists(`${CLIENTS_DIRECTORY}/${name}/src/runtime.ts`))
|
|
22
|
+
.map((name) => `${CLIENTS_DIRECTORY}/${name}`);
|
|
23
|
+
}
|
|
24
|
+
function writeClient(ws, config, { document, packageName, directory }) {
|
|
25
|
+
for (const [file, content] of clientFiles(document, packageName, directory)) {
|
|
26
|
+
putFile(ws, `${directory}/${file}`, content);
|
|
27
|
+
}
|
|
28
|
+
const manifest = `${directory}/package.json`;
|
|
29
|
+
const facts = { name: packageName, version: document.version, title: document.title, access: config.sdk?.access };
|
|
30
|
+
putFile(ws, manifest, clientManifest(facts, ws.read(manifest)));
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=write-clients.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write-clients.js","sourceRoot":"","sources":["../../src/sdk/write-clients.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,EAAa,EAAE,MAAc,EAAE,OAAiC;IAC3F,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,CACL,EAAE,EACF,GAAG,iBAAiB,gBAAgB,EACpC,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC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const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.6.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.6.0';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The value of a YAML text written by `toYaml`, which is how the kit writes its contracts: block
|
|
3
|
+
* maps and lists indented by two spaces, plain, single-quoted and double-quoted scalars, literal
|
|
4
|
+
* blocks, and `{}` and `[]` for what is empty. Anything else (a flow collection with content, an
|
|
5
|
+
* anchor, a comment, a folded block) is not something the kit wrote: it throws `YamlShapeError`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function fromYaml(text: string): unknown;
|
|
8
|
+
//# sourceMappingURL=from-yaml.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"from-yaml.d.ts","sourceRoot":"","sources":["../../src/yaml/from-yaml.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAa9C"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { readScalar } from './read-scalar.js';
|
|
2
|
+
import { YamlShapeError } from './yaml-shape-error.js';
|
|
3
|
+
const INDENT = 2;
|
|
4
|
+
const BLOCK_HEADER = /^\|(\d)?([-+])?$/;
|
|
5
|
+
/**
|
|
6
|
+
* The value of a YAML text written by `toYaml`, which is how the kit writes its contracts: block
|
|
7
|
+
* maps and lists indented by two spaces, plain, single-quoted and double-quoted scalars, literal
|
|
8
|
+
* blocks, and `{}` and `[]` for what is empty. Anything else (a flow collection with content, an
|
|
9
|
+
* anchor, a comment, a folded block) is not something the kit wrote: it throws `YamlShapeError`.
|
|
10
|
+
*/
|
|
11
|
+
export function fromYaml(text) {
|
|
12
|
+
const lines = text.replaceAll('\r\n', '\n').split('\n');
|
|
13
|
+
if (lines.at(-1) === '') {
|
|
14
|
+
lines.pop();
|
|
15
|
+
}
|
|
16
|
+
const reader = new YamlReader(lines);
|
|
17
|
+
const value = reader.value(0);
|
|
18
|
+
reader.expectEnd();
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
class YamlReader {
|
|
22
|
+
lines;
|
|
23
|
+
position = 0;
|
|
24
|
+
constructor(lines) {
|
|
25
|
+
this.lines = lines;
|
|
26
|
+
}
|
|
27
|
+
/** The value whose first line is the current one, at an indentation. */
|
|
28
|
+
value(indent) {
|
|
29
|
+
const line = this.current();
|
|
30
|
+
if (line === undefined) {
|
|
31
|
+
throw new YamlShapeError(this.position, 'a value is missing');
|
|
32
|
+
}
|
|
33
|
+
const body = line.slice(indent);
|
|
34
|
+
if (body.startsWith('- ')) {
|
|
35
|
+
return this.list(indent);
|
|
36
|
+
}
|
|
37
|
+
return isEntry(body) ? this.map(indent) : this.lone(body, indent);
|
|
38
|
+
}
|
|
39
|
+
expectEnd() {
|
|
40
|
+
if (this.position < this.lines.length) {
|
|
41
|
+
throw new YamlShapeError(this.position, 'this line is not under the value before it');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
current() {
|
|
45
|
+
return this.lines[this.position];
|
|
46
|
+
}
|
|
47
|
+
/** A scalar alone on its line, the lines of its literal block at `blockIndent`: the whole document, or an item of a list after its dash. */
|
|
48
|
+
lone(body, blockIndent) {
|
|
49
|
+
this.position += 1;
|
|
50
|
+
return this.inline(body, blockIndent);
|
|
51
|
+
}
|
|
52
|
+
map(indent) {
|
|
53
|
+
const map = {};
|
|
54
|
+
while (this.startsAt(indent) && !this.lineBody(indent).startsWith('- ')) {
|
|
55
|
+
const [key, rest] = splitEntry(this.lineBody(indent), this.position);
|
|
56
|
+
map[key] = this.entryValue(rest, indent);
|
|
57
|
+
}
|
|
58
|
+
return map;
|
|
59
|
+
}
|
|
60
|
+
list(indent) {
|
|
61
|
+
const list = [];
|
|
62
|
+
while (this.startsAt(indent) && this.lineBody(indent).startsWith('- ')) {
|
|
63
|
+
list.push(this.item(indent));
|
|
64
|
+
}
|
|
65
|
+
return list;
|
|
66
|
+
}
|
|
67
|
+
/** An item: what follows its dash is read as if it began a line two columns further in. */
|
|
68
|
+
item(indent) {
|
|
69
|
+
const inner = indent + INDENT;
|
|
70
|
+
const body = this.lineBody(indent).slice(INDENT);
|
|
71
|
+
if (body.startsWith('- ') || isEntry(body)) {
|
|
72
|
+
this.replaceCurrent(' '.repeat(inner) + body);
|
|
73
|
+
return this.value(inner);
|
|
74
|
+
}
|
|
75
|
+
return this.lone(body, inner);
|
|
76
|
+
}
|
|
77
|
+
/** The value of `key:` (nested on the lines below) or `key: value`. */
|
|
78
|
+
entryValue(rest, indent) {
|
|
79
|
+
this.position += 1;
|
|
80
|
+
if (rest !== undefined) {
|
|
81
|
+
return this.inline(rest, indent + INDENT);
|
|
82
|
+
}
|
|
83
|
+
const next = this.current();
|
|
84
|
+
const inner = indent + INDENT;
|
|
85
|
+
if (next === undefined || indentOf(next) < inner) {
|
|
86
|
+
throw new YamlShapeError(this.position, 'a key has no value');
|
|
87
|
+
}
|
|
88
|
+
return this.value(inner);
|
|
89
|
+
}
|
|
90
|
+
/** A value on the line of its key or dash, the line just read; a literal block takes the lines below, at `blockIndent`. */
|
|
91
|
+
inline(text, blockIndent) {
|
|
92
|
+
const header = BLOCK_HEADER.exec(text);
|
|
93
|
+
return header === null ? readScalar(text, this.position - 1) : this.literal(header[2] ?? '', blockIndent);
|
|
94
|
+
}
|
|
95
|
+
literal(chomping, blockIndent) {
|
|
96
|
+
const body = [];
|
|
97
|
+
while (this.position < this.lines.length) {
|
|
98
|
+
const line = this.current() ?? '';
|
|
99
|
+
if (line !== '' && indentOf(line) < blockIndent) {
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
body.push(line.slice(blockIndent));
|
|
103
|
+
this.position += 1;
|
|
104
|
+
}
|
|
105
|
+
return chomped(body, chomping);
|
|
106
|
+
}
|
|
107
|
+
startsAt(indent) {
|
|
108
|
+
const line = this.current();
|
|
109
|
+
return line !== undefined && indentOf(line) === indent;
|
|
110
|
+
}
|
|
111
|
+
lineBody(indent) {
|
|
112
|
+
return (this.current() ?? '').slice(indent);
|
|
113
|
+
}
|
|
114
|
+
/** The rest of a line after a dash, put back as the line it would be on its own. */
|
|
115
|
+
replaceCurrent(line) {
|
|
116
|
+
this.lines[this.position] = line;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function indentOf(line) {
|
|
120
|
+
return line.length - line.trimStart().length;
|
|
121
|
+
}
|
|
122
|
+
/** A line that holds a key: a quoted key followed by a colon, or a plain one up to its first `: ` or its final colon. */
|
|
123
|
+
function isEntry(body) {
|
|
124
|
+
if (body.startsWith("'") || body.startsWith('"')) {
|
|
125
|
+
return /^(?:'(?:[^']|'')*'|"(?:[^"\\]|\\.)*"):(?: |$)/.test(body);
|
|
126
|
+
}
|
|
127
|
+
return body.includes(': ') || (body.endsWith(':') && !BLOCK_HEADER.test(body));
|
|
128
|
+
}
|
|
129
|
+
/** The key of an entry and what follows its colon on the same line, if anything. */
|
|
130
|
+
function splitEntry(body, line) {
|
|
131
|
+
const quoted = /^('(?:[^']|'')*'|"(?:[^"\\]|\\.)*"):(?: (.*))?$/.exec(body);
|
|
132
|
+
if (quoted !== null) {
|
|
133
|
+
return [String(readScalar(quoted[1] ?? '', line)), quoted[2]];
|
|
134
|
+
}
|
|
135
|
+
const separator = body.indexOf(': ');
|
|
136
|
+
return separator === -1 ? [body.slice(0, -1), undefined] : [body.slice(0, separator), body.slice(separator + 2)];
|
|
137
|
+
}
|
|
138
|
+
/** `|` keeps one final line break, `|-` none, `|+` every one. */
|
|
139
|
+
function chomped(body, chomping) {
|
|
140
|
+
if (chomping === '+') {
|
|
141
|
+
return `${body.join('\n')}\n`;
|
|
142
|
+
}
|
|
143
|
+
const kept = [...body];
|
|
144
|
+
while (kept.at(-1) === '') {
|
|
145
|
+
kept.pop();
|
|
146
|
+
}
|
|
147
|
+
return chomping === '-' ? kept.join('\n') : `${kept.join('\n')}\n`;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=from-yaml.js.map
|