@astryxdesign/cli 0.6.3-canary.98a2e4e → 0.6.3-canary.a860a50
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 +32 -18
- package/api/build/build.doc.mjs +3 -3
- package/api/build/build.test.mjs +14 -3
- package/api/build/build.type.d.mts +36 -2
- package/api/build/build.type.mjs +25 -4
- package/api/build/help/help.d.mts +8 -5
- package/api/build/help/help.mjs +56 -6
- package/api/component/component.doc.mjs +11 -2
- package/api/component/component.mjs +29 -0
- package/api/component/component.test.mjs +38 -0
- package/api/component/component.type.d.mts +17 -7
- package/api/component/component.type.mjs +27 -20
- package/api/discover/discover.doc.mjs +1 -1
- package/api/discover/discover.type.d.mts +4 -4
- package/api/discover/discover.type.mjs +10 -10
- package/api/docs/_adapter.d.mts +30 -27
- package/api/docs/_adapter.mjs +154 -124
- package/api/docs/compiled-topics.test.mjs +78 -0
- package/api/docs/detail/detail.d.mts +0 -15
- package/api/docs/detail/detail.mjs +14 -78
- package/api/docs/detail/section/section.mjs +22 -18
- package/api/docs/detail/section/section.test.mjs +4 -3
- package/api/docs/docs.type.d.mts +4 -4
- package/api/docs/docs.type.mjs +10 -10
- package/api/docs/index/index.mjs +6 -5
- package/api/doctor/doctor.mjs +3 -7
- package/api/gap-report/gap-report.doc.mjs +7 -4
- package/api/hook/hook.type.d.mts +3 -3
- package/api/hook/hook.type.mjs +11 -11
- package/api/init/init.doc.mjs +4 -0
- package/api/init/init.test.mjs +41 -1
- package/api/init/remove/remove.mjs +1 -1
- package/api/init/run/run.mjs +20 -10
- package/api/integration/add-contribution.component-names.test.mjs +120 -0
- package/api/integration/add-contribution.mjs +16 -3
- package/api/integration/add-contribution.test.mjs +84 -4
- package/api/integration/integrationAdd.doc.mjs +7 -4
- package/api/integration/integrationAddComponent.doc.mjs +1 -1
- package/api/integration/pack-check.mjs +49 -7
- package/api/integration/pack-check.test.mjs +249 -0
- package/api/integration/validate-integration.mjs +2 -0
- package/api/integration/validate-integration.test.mjs +91 -0
- package/api/integration/validateIntegration.doc.mjs +1 -1
- package/api/json/envelope-types.test.mjs +76 -0
- package/api/json/parseResponse.doc.mjs +2 -2
- package/api/layout/expand/expand.mjs +7 -5
- package/api/layout/expand/expand.path-safety.test.mjs +53 -0
- package/api/layout/grammar/grammar.mjs +2 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/search/search-return-type.test.mjs +54 -0
- package/api/search/search.d.mts +2 -9
- package/api/search/search.doc.mjs +5 -1
- package/api/search/search.mjs +15 -8
- package/api/search/search.test.mjs +34 -0
- package/api/search/search.type.d.mts +1 -1
- package/api/search/search.type.mjs +1 -1
- package/api/swizzle/copy/copy.mjs +28 -11
- package/api/swizzle/swizzle.doc.mjs +1 -1
- package/api/swizzle/swizzle.type.d.mts +2 -2
- package/api/swizzle/swizzle.type.mjs +2 -2
- package/api/template/copy/copy.mjs +17 -23
- package/api/template/copy/copy.test.mjs +17 -0
- package/api/template/template.doc.mjs +2 -1
- package/api/template/template.type.d.mts +5 -5
- package/api/template/template.type.mjs +12 -12
- package/api/theme/add/add.binary.test.mjs +91 -0
- package/api/theme/add/add.mjs +15 -2
- package/api/theme/build/build.mjs +133 -42
- package/api/theme/build/build.public-component-vars.test.mjs +1 -1
- package/api/theme/build/build.receipt-doc.test.mjs +111 -0
- package/api/theme/build/build.test.mjs +127 -0
- package/api/theme/build/font-warning.mjs +3 -3
- package/api/theme/build/font-warning.test.mjs +5 -2
- package/api/theme/palette/generate/generate.mjs +8 -3
- package/api/theme/palette/generate/generate.test.mjs +96 -0
- package/api/theme/palette/generate/generator.d.mts +10 -13
- package/api/theme/palette/generate/generator.mjs +15 -4
- package/api/theme/palette/generate/generator.test.mjs +10 -0
- package/api/theme/template/template.mjs +11 -2
- package/api/theme/template/template.test.mjs +15 -0
- package/api/theme/theme.type.d.mts +170 -11
- package/api/theme/theme.type.mjs +94 -27
- package/api/theme/themeBuild.doc.mjs +7 -4
- package/api/theme/themeTemplate.doc.mjs +4 -1
- package/api/upgrade/_adapter.mjs +27 -4
- package/api/upgrade/list/list.mjs +2 -1
- package/api/upgrade/list/list.test.mjs +73 -0
- package/api/upgrade/status/status.mjs +2 -2
- package/api/upgrade/upgrade.doc.mjs +2 -1
- package/api/upgrade/upgrade.type.d.mts +8 -4
- package/api/upgrade/upgrade.type.mjs +11 -10
- package/assets/codemods/integration-discovery.mjs +40 -2
- package/assets/codemods/integration-discovery.test.mjs +58 -0
- package/assets/codemods/term-log.mjs +32 -8
- package/assets/codemods/term-log.test.mjs +19 -1
- package/assets/codemods/transforms/v0.3.0/__tests__/unwrap-authoring-factories.test.mjs +27 -5
- package/assets/codemods/transforms/v0.3.0/unwrap-authoring-factories.mjs +20 -5
- package/assets/codemods/transforms/v0.6.0/__tests__/next-codemods.test.mjs +47 -0
- package/assets/codemods/transforms/v0.6.0/rename-resizable-pixel-bounds.mjs +57 -10
- package/assets/docs/cli-integrations.doc.mjs +9 -0
- package/assets/docs/styling-libraries.doc.mjs +1 -1
- package/assets/docs/working-with-ai.doc.mjs +1 -1
- package/assets/templates/pages/table-tree/page.tsx +1704 -0
- package/assets/templates/pages/table-tree/template.doc.mjs +12 -0
- package/authoring/_shared/contract.ts +22 -0
- package/authoring/codemod/codemod.doc.mjs +6 -1
- package/authoring/codemod/parse.d.mts +8 -8
- package/authoring/codemod/parse.mjs +8 -6
- package/authoring/config/config.doc.mjs +1 -1
- package/authoring/config/debug-composition.test.mjs +92 -0
- package/authoring/config/parse.d.mts +13 -13
- package/authoring/config/parse.mjs +8 -8
- package/authoring/config/type.ts +18 -6
- package/authoring/debug/parse.d.mts +4 -4
- package/authoring/debug/parse.mjs +3 -3
- package/authoring/doctypes/_schema.d.mts +121 -11
- package/authoring/doctypes/_schema.mjs +144 -13
- package/authoring/doctypes/base/graph-fields.doc.mjs +11 -4
- package/authoring/doctypes/base/type.ts +8 -4
- package/authoring/doctypes/command/command.doc.mjs +3 -2
- package/authoring/doctypes/command/parse.d.mts +2 -2
- package/authoring/doctypes/command/parse.mjs +1 -1
- package/authoring/doctypes/command/type.ts +2 -2
- package/authoring/doctypes/component/component.doc.mjs +5 -2
- package/authoring/doctypes/component/parse.d.mts +2 -2
- package/authoring/doctypes/component/parse.mjs +1 -1
- package/authoring/doctypes/component/type.ts +1 -1
- package/authoring/doctypes/enum/parse.d.mts +2 -2
- package/authoring/doctypes/enum/parse.mjs +1 -1
- package/authoring/doctypes/enum/type.ts +1 -1
- package/authoring/doctypes/function/function.doc.mjs +4 -0
- package/authoring/doctypes/function/parse.d.mts +2 -2
- package/authoring/doctypes/function/parse.mjs +1 -1
- package/authoring/doctypes/function/type.ts +1 -1
- package/authoring/doctypes/hook/hook.doc.mjs +4 -0
- package/authoring/doctypes/hook/parse.d.mts +2 -2
- package/authoring/doctypes/hook/parse.mjs +1 -1
- package/authoring/doctypes/hook/type.ts +1 -1
- package/authoring/doctypes/legacy.d.mts +6 -6
- package/authoring/doctypes/legacy.mjs +3 -3
- package/authoring/doctypes/load-contract.test.mjs +207 -0
- package/authoring/doctypes/namespace/namespace.doc.mjs +7 -3
- package/authoring/doctypes/namespace/parse.d.mts +2 -2
- package/authoring/doctypes/namespace/parse.mjs +1 -1
- package/authoring/doctypes/namespace/type.ts +2 -2
- package/authoring/doctypes/parse.d.mts +18 -18
- package/authoring/doctypes/parse.mjs +9 -9
- package/authoring/doctypes/reference/parse.d.mts +2 -2
- package/authoring/doctypes/reference/parse.mjs +1 -1
- package/authoring/doctypes/reference/reference.doc.mjs +6 -2
- package/authoring/doctypes/reference/type.ts +1 -1
- package/authoring/doctypes/schema/parse.d.mts +2 -2
- package/authoring/doctypes/schema/parse.mjs +1 -1
- package/authoring/doctypes/schema/type.ts +2 -2
- package/authoring/doctypes/template/parse.d.mts +92 -1
- package/authoring/doctypes/template/parse.mjs +33 -1
- package/authoring/doctypes/template/template.doc.mjs +4 -0
- package/authoring/doctypes/template/type.ts +4 -1
- package/authoring/doctypes/types.ts +10 -10
- package/authoring/gap-report/parse.d.mts +9 -9
- package/authoring/gap-report/parse.mjs +6 -6
- package/authoring/gap-report/type.ts +1 -1
- package/authoring/identity/identity.doc.mjs +3 -2
- package/authoring/identity/type.ts +10 -10
- package/authoring/index.d.ts +19 -19
- package/authoring/integration/parse.d.mts +2 -2
- package/authoring/integration/parse.mjs +1 -1
- package/authoring/integration/schema.d.mts +4 -4
- package/authoring/integration/schema.mjs +3 -3
- package/authoring/integration/type.ts +1 -1
- package/clients/cli/command-load-failure.test.mjs +83 -0
- package/clients/cli/commands/blog.mjs +23 -8
- package/clients/cli/commands/blog.test.mjs +42 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +161 -0
- package/clients/cli/commands/build-theme.flag-docs.test.mjs +110 -0
- package/clients/cli/commands/build-theme.mjs +5 -5
- package/clients/cli/commands/build-theme.path-safety.test.mjs +86 -1
- package/clients/cli/commands/build-theme.variants.test.mjs +76 -0
- package/clients/cli/commands/build.doc.mjs +4 -1
- package/clients/cli/commands/build.exit-codes-doc.test.mjs +50 -0
- package/clients/cli/commands/build.mjs +32 -47
- package/clients/cli/commands/build.playbook.test.mjs +75 -0
- package/clients/cli/commands/build.text-fields.test.mjs +40 -0
- package/clients/cli/commands/component/index.mjs +2 -7
- package/clients/cli/commands/component-package.test.mjs +18 -0
- package/clients/cli/commands/component-resolution.test.mjs +21 -0
- package/clients/cli/commands/component.test.mjs +19 -0
- package/clients/cli/commands/detail-levels.test.mjs +2 -2
- package/clients/cli/commands/discover.broken-integration.test.mjs +48 -0
- package/clients/cli/commands/discover.components-flag.test.mjs +97 -0
- package/clients/cli/commands/discover.doc.mjs +4 -2
- package/clients/cli/commands/discover.mjs +3 -3
- package/clients/cli/commands/discover.text-projection.test.mjs +103 -0
- package/clients/cli/commands/doctor-integration.package-json.test.mjs +53 -0
- package/clients/cli/commands/doctor.mjs +6 -16
- package/clients/cli/commands/doctor.test.mjs +42 -0
- package/clients/cli/commands/gap-report.doc.mjs +16 -5
- package/clients/cli/commands/gap-report.test.mjs +72 -0
- package/clients/cli/commands/hook/index.mjs +7 -17
- package/clients/cli/commands/hook.text-projection.test.mjs +45 -0
- package/clients/cli/commands/init.doc.mjs +19 -8
- package/clients/cli/commands/init.flag-help.test.mjs +153 -0
- package/clients/cli/commands/integration-add.controls.test.mjs +132 -0
- package/clients/cli/commands/integration-add.doc.mjs +21 -5
- package/clients/cli/commands/integration-authoring.test.mjs +13 -9
- package/clients/cli/commands/interactive-guard.test.mjs +101 -24
- package/clients/cli/commands/json-contract.test.mjs +33 -0
- package/clients/cli/commands/layout-check.doc.mjs +14 -3
- package/clients/cli/commands/layout-expand.doc.mjs +21 -4
- package/clients/cli/commands/layout.doc.mjs +2 -2
- package/clients/cli/commands/layout.mjs +21 -9
- package/clients/cli/commands/layout.path-help.test.mjs +33 -0
- package/clients/cli/commands/layout.stdin-cap.test.mjs +47 -0
- package/clients/cli/commands/layout.text-fields.test.mjs +39 -0
- package/clients/cli/commands/no-prompt-wording.test.mjs +94 -0
- package/clients/cli/commands/search.doc.mjs +5 -2
- package/clients/cli/commands/search.mjs +13 -2
- package/clients/cli/commands/search.test.mjs +61 -0
- package/clients/cli/commands/swizzle.doc.mjs +2 -1
- package/clients/cli/commands/swizzle.path-safety.test.mjs +42 -0
- package/clients/cli/commands/template.doc.mjs +28 -6
- package/clients/cli/commands/template.flag-help.test.mjs +117 -0
- package/clients/cli/commands/template.path-help.test.mjs +40 -0
- package/clients/cli/commands/theme-add.doc.mjs +2 -1
- package/clients/cli/commands/theme-build.doc.mjs +7 -6
- package/clients/cli/commands/theme-palette-generate.test.mjs +19 -0
- package/clients/cli/commands/theme-template.behavior.test.mjs +12 -0
- package/clients/cli/commands/theme-template.doc.mjs +1 -1
- package/clients/cli/commands/upgrade.ascii-output.test.mjs +87 -0
- package/clients/cli/commands/upgrade.doc.mjs +17 -6
- package/clients/cli/commands/upgrade.flag-help.test.mjs +188 -0
- package/clients/cli/commands/upgrade.hook-output.test.mjs +88 -0
- package/clients/cli/index.mjs +13 -30
- package/clients/cli/latest-version-env.test.mjs +50 -0
- package/clients/cli/lib/cli-error.test.mjs +7 -0
- package/clients/cli/lib/component-format.mjs +9 -9
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +32 -6
- package/clients/cli/lib/doc-text-ascii.test.mjs +82 -0
- package/clients/cli/lib/exit-codes.test.mjs +97 -0
- package/clients/cli/lib/hook-format.mjs +5 -5
- package/clients/cli/lib/json-shim.mjs +38 -2
- package/clients/cli/lib/json-shim.test.mjs +83 -0
- package/clients/cli/lib/manifest.d.ts +2 -0
- package/clients/cli/lib/manifest.mjs +22 -0
- package/clients/cli/lib/manifest.test.mjs +17 -0
- package/foundation/agent-docs/agent-docs.d.mts +4 -0
- package/foundation/agent-docs/agent-docs.mjs +69 -3
- package/foundation/agent-docs/agent-docs.path-safety.test.mjs +266 -4
- package/foundation/config/integration-debug.test.mjs +28 -3
- package/foundation/config/project.mjs +123 -9
- package/foundation/config/project.test.mjs +126 -0
- package/foundation/discovery/authoring-self-docs.test.mjs +71 -12
- package/foundation/discovery/docs-discovery.d.mts +4 -0
- package/foundation/discovery/docs-discovery.mjs +16 -2
- package/foundation/discovery/docs-discovery.test.mjs +47 -11
- package/foundation/discovery/template-adapter.d.mts +14 -5
- package/foundation/discovery/template-adapter.fixture-refs.test.mjs +248 -0
- package/foundation/discovery/template-adapter.integration-isolation.test.mjs +94 -0
- package/foundation/discovery/template-adapter.mjs +292 -25
- package/foundation/discovery/theming-targets.test.mjs +4 -0
- package/foundation/doc-compiler/compile.d.mts +162 -0
- package/foundation/doc-compiler/compile.mjs +262 -0
- package/foundation/doc-compiler/doc-compiler.test.mjs +687 -0
- package/foundation/doc-compiler/ir.d.mts +9 -0
- package/foundation/doc-compiler/ir.mjs +287 -0
- package/foundation/doc-compiler/lenses.d.mts +33 -0
- package/foundation/doc-compiler/lenses.mjs +127 -0
- package/foundation/fs/module-loader.d.mts +1 -0
- package/foundation/fs/module-loader.mjs +50 -1
- package/foundation/fs/module-loader.stdout.test.mjs +332 -0
- package/foundation/fs/path-safety.d.mts +3 -2
- package/foundation/fs/path-safety.mjs +49 -19
- package/foundation/fs/path-safety.test.mjs +50 -0
- package/foundation/fs/publish-file-hardlink-unavailable.test.mjs +129 -94
- package/foundation/integrations/autolink.mjs +6 -1
- package/foundation/response/base.d.ts +8 -4
- package/foundation/response/error-codes.doc.mjs +1 -2
- package/foundation/response/error-codes.mjs +1 -1
- package/foundation/response/error-codes.test.mjs +83 -0
- package/foundation/response/json-contract.test.mjs +11 -0
- package/foundation/response/json.d.mts +4 -2
- package/foundation/response/json.mjs +8 -10
- package/foundation/response/response-types.doc.mjs +3 -3
- package/foundation/xle/expand.d.mts +2 -0
- package/foundation/xle/expand.mjs +3 -2
- package/foundation/xle/expand.test.mjs +54 -0
- package/package.json +9 -11
- package/clients/cli/lib/update-check.mjs +0 -83
- package/clients/cli/lib/update-check.test.mjs +0 -137
- package/clients/cli/update-hint-commands.test.mjs +0 -54
|
@@ -53,7 +53,7 @@ export const doc = {
|
|
|
53
53
|
{
|
|
54
54
|
type: 'search',
|
|
55
55
|
description:
|
|
56
|
-
'The query echoed back, `matchCount` (how many candidates matched in total, before `limit`), plus a ranked SearchResultEntry[] bounded by `limit
|
|
56
|
+
'The query echoed back, `matchCount` (how many candidates matched in total, before `limit`), plus a ranked SearchResultEntry[] bounded by `limit`: each has domain, name, score, reason, description, and follow-up command, plus `import` for components and hooks, `title` for docs, and `displayName` and `kind` for templates.',
|
|
57
57
|
},
|
|
58
58
|
],
|
|
59
59
|
throws: [
|
|
@@ -61,6 +61,10 @@ export const doc = {
|
|
|
61
61
|
code: 'ERR_INVALID_ARGUMENT',
|
|
62
62
|
when: 'the query is empty, --type is unknown, or --limit is not a positive integer',
|
|
63
63
|
},
|
|
64
|
+
{
|
|
65
|
+
code: 'ERR_CORE_NOT_FOUND',
|
|
66
|
+
when: '@astryxdesign/core cannot be found from the cwd',
|
|
67
|
+
},
|
|
64
68
|
],
|
|
65
69
|
examples: [
|
|
66
70
|
{label: 'Find a component', code: "const r = await search('button');"},
|
package/api/search/search.mjs
CHANGED
|
@@ -66,7 +66,7 @@ import {
|
|
|
66
66
|
import {loadIntegrationsSafely} from '../component/_adapter.mjs';
|
|
67
67
|
import {levenshteinDistance} from '../../foundation/text/string-utils.mjs';
|
|
68
68
|
import {discoverTemplates, extractComponents} from '../template/template.mjs';
|
|
69
|
-
import {loadDocsCatalog,
|
|
69
|
+
import {loadDocsCatalog, lowerTopic} from '../docs/_adapter.mjs';
|
|
70
70
|
import {AstryxError} from '../error.mjs';
|
|
71
71
|
import {ERROR_CODES} from '../../foundation/response/error-codes.mjs';
|
|
72
72
|
import {setResultCoverage} from './coverage.mjs';
|
|
@@ -732,16 +732,16 @@ async function gatherHooks(coreDir) {
|
|
|
732
732
|
async function gatherDocs(cwd) {
|
|
733
733
|
/** @type {Candidate[]} */
|
|
734
734
|
const candidates = [];
|
|
735
|
-
let
|
|
735
|
+
let catalog;
|
|
736
736
|
try {
|
|
737
|
-
|
|
737
|
+
catalog = await loadDocsCatalog(cwd);
|
|
738
738
|
} catch {
|
|
739
739
|
return candidates;
|
|
740
740
|
}
|
|
741
|
-
for (const entry of entries) {
|
|
741
|
+
for (const entry of catalog.entries()) {
|
|
742
742
|
let doc = null;
|
|
743
743
|
try {
|
|
744
|
-
doc = await
|
|
744
|
+
doc = (await lowerTopic(catalog, entry)).doc;
|
|
745
745
|
} catch {
|
|
746
746
|
// A topic that cannot be loaded is reported by the commands that own
|
|
747
747
|
// integration issues; search just cannot index it.
|
|
@@ -884,7 +884,7 @@ function toResult(c, score, reason, matchedTerms, queryTerms) {
|
|
|
884
884
|
* @param {string} [options.cwd]
|
|
885
885
|
* @param {'component'|'hook'|'doc'|'template'} [options.type] - Restrict to one domain.
|
|
886
886
|
* @param {number} [options.limit] - Max results (default 20).
|
|
887
|
-
* @returns {Promise<
|
|
887
|
+
* @returns {Promise<import('./search.type.mjs').SearchResponse>}
|
|
888
888
|
*/
|
|
889
889
|
export async function search(query, options = {}) {
|
|
890
890
|
const {cwd = process.cwd(), type, limit = 20} = options;
|
|
@@ -921,7 +921,11 @@ export async function search(query, options = {}) {
|
|
|
921
921
|
|
|
922
922
|
const coreDir = findCoreDir(cwd);
|
|
923
923
|
if (!coreDir) {
|
|
924
|
-
throw new AstryxError(
|
|
924
|
+
throw new AstryxError(
|
|
925
|
+
'Could not find @astryxdesign/core package',
|
|
926
|
+
undefined,
|
|
927
|
+
ERROR_CODES.ERR_CORE_NOT_FOUND,
|
|
928
|
+
);
|
|
925
929
|
}
|
|
926
930
|
|
|
927
931
|
// Gather candidates from each requested domain in parallel.
|
|
@@ -971,7 +975,10 @@ export async function search(query, options = {}) {
|
|
|
971
975
|
data: {
|
|
972
976
|
query: String(query).trim(),
|
|
973
977
|
matchCount: scored.length,
|
|
974
|
-
|
|
978
|
+
// toResult gives every domain its command and domain fields.
|
|
979
|
+
results: /** @type {import('./search.type.mjs').SearchResultEntry[]} */ (
|
|
980
|
+
limited
|
|
981
|
+
),
|
|
975
982
|
},
|
|
976
983
|
};
|
|
977
984
|
}
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
import {describe, it, expect} from 'vitest';
|
|
23
23
|
import * as fs from 'node:fs';
|
|
24
|
+
import * as os from 'node:os';
|
|
24
25
|
import * as path from 'node:path';
|
|
25
26
|
import {fileURLToPath} from 'node:url';
|
|
26
27
|
import {
|
|
@@ -70,6 +71,28 @@ describe('search leaf — envelope + ranking', () => {
|
|
|
70
71
|
}, SLOW);
|
|
71
72
|
});
|
|
72
73
|
|
|
74
|
+
describe('search leaf — per-domain result fields', () => {
|
|
75
|
+
it('carries import for components and hooks, title for docs, displayName and kind for templates', async () => {
|
|
76
|
+
const r = await search('theme', {cwd, limit: 60});
|
|
77
|
+
expect(new Set(r.data.results.map(res => res.domain))).toEqual(
|
|
78
|
+
new Set(SEARCH_DOMAINS),
|
|
79
|
+
);
|
|
80
|
+
for (const res of r.data.results) {
|
|
81
|
+
expect(typeof res.command).toBe('string');
|
|
82
|
+
expect(typeof res.description).toBe('string');
|
|
83
|
+
if (res.domain === 'component' || res.domain === 'hook') {
|
|
84
|
+
expect(res.import).toMatch(/\S/);
|
|
85
|
+
} else if (res.domain === 'doc') {
|
|
86
|
+
expect(res.title).toMatch(/\S/);
|
|
87
|
+
expect(res.command).toBe(`astryx docs ${res.name}`);
|
|
88
|
+
} else {
|
|
89
|
+
expect(res.displayName).toMatch(/\S/);
|
|
90
|
+
expect(['page', 'block']).toContain(res.kind);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}, SLOW);
|
|
94
|
+
});
|
|
95
|
+
|
|
73
96
|
describe('search leaf — matchCount is the total, not the cap', () => {
|
|
74
97
|
it('reports every match while `results` stays bounded by the limit', async () => {
|
|
75
98
|
// The regression: `matchCount` used to be `results.length`, so a query
|
|
@@ -160,6 +183,17 @@ describe('search leaf — error paths (pinned)', () => {
|
|
|
160
183
|
search('button', {cwd, type: /** @type {any} */ ('bogus')}),
|
|
161
184
|
).rejects.toMatchObject({code: 'ERR_INVALID_ARGUMENT'});
|
|
162
185
|
}, SLOW);
|
|
186
|
+
|
|
187
|
+
it('throws ERR_CORE_NOT_FOUND when @astryxdesign/core cannot be found', async () => {
|
|
188
|
+
const empty = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-search-no-core-'));
|
|
189
|
+
try {
|
|
190
|
+
await expect(search('button', {cwd: empty})).rejects.toMatchObject({
|
|
191
|
+
code: 'ERR_CORE_NOT_FOUND',
|
|
192
|
+
});
|
|
193
|
+
} finally {
|
|
194
|
+
fs.rmSync(empty, {recursive: true, force: true});
|
|
195
|
+
}
|
|
196
|
+
}, SLOW);
|
|
163
197
|
});
|
|
164
198
|
|
|
165
199
|
describe('search leaf — limit validation (API matches the CLI contract)', () => {
|
|
@@ -159,6 +159,24 @@ function resolveOwners(coreDir, loadedIntegrations, name, coreIssuesUrl) {
|
|
|
159
159
|
return owners;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
/**
|
|
163
|
+
* `assertWithin`, with an escape reported as ERR_PATH_TRAVERSAL.
|
|
164
|
+
* @param {string} target
|
|
165
|
+
* @param {string} cwd
|
|
166
|
+
* @param {{allowAbsolute?: boolean, label: string}} options
|
|
167
|
+
* @returns {string}
|
|
168
|
+
*/
|
|
169
|
+
function confineWrite(target, cwd, options) {
|
|
170
|
+
try {
|
|
171
|
+
return assertWithin(target, cwd, options);
|
|
172
|
+
} catch (err) {
|
|
173
|
+
if (err instanceof PathSafetyError) {
|
|
174
|
+
throw new AstryxError(err.message, [], ERROR_CODES.ERR_PATH_TRAVERSAL);
|
|
175
|
+
}
|
|
176
|
+
throw err;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
162
180
|
/** @param {string} file */
|
|
163
181
|
function isExcludedFromCopy(file) {
|
|
164
182
|
return (
|
|
@@ -243,23 +261,22 @@ export async function swizzleCopy(component, options = {}) {
|
|
|
243
261
|
|
|
244
262
|
const componentDir = owner.sourceDir;
|
|
245
263
|
|
|
246
|
-
// Path-safety:
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
outputBase = assertWithin(output, cwd, {label: 'output directory'});
|
|
250
|
-
} catch (err) {
|
|
251
|
-
if (err instanceof PathSafetyError) {
|
|
252
|
-
throw new AstryxError(err.message, [], ERROR_CODES.ERR_PATH_TRAVERSAL);
|
|
253
|
-
}
|
|
254
|
-
throw err;
|
|
255
|
-
}
|
|
264
|
+
// Path-safety: every write target resolves inside cwd, not just --output. An
|
|
265
|
+
// existing component directory or file may be a symlink out of cwd.
|
|
266
|
+
const outputBase = confineWrite(output, cwd, {label: 'output directory'});
|
|
256
267
|
const outputDir = path.join(outputBase, dirName);
|
|
257
268
|
|
|
258
|
-
// Pre-flight overwrite
|
|
269
|
+
// Pre-flight path and overwrite checks before any mkdir/writeFile.
|
|
259
270
|
const sourceFiles = fs.readdirSync(componentDir).filter(file => {
|
|
260
271
|
if (isExcludedFromCopy(file)) return false;
|
|
261
272
|
return fs.statSync(path.join(componentDir, file)).isFile();
|
|
262
273
|
});
|
|
274
|
+
for (const file of sourceFiles) {
|
|
275
|
+
confineWrite(path.join(outputDir, file), cwd, {
|
|
276
|
+
allowAbsolute: true,
|
|
277
|
+
label: 'output file',
|
|
278
|
+
});
|
|
279
|
+
}
|
|
263
280
|
const existingFiles = sourceFiles.filter(f =>
|
|
264
281
|
fs.existsSync(path.join(outputDir, f)),
|
|
265
282
|
);
|
|
@@ -80,7 +80,7 @@ export const doc = {
|
|
|
80
80
|
},
|
|
81
81
|
{
|
|
82
82
|
code: 'ERR_PATH_TRAVERSAL',
|
|
83
|
-
when: 'the component name contains a path separator or traversal, or output resolves outside cwd',
|
|
83
|
+
when: 'the component name contains a path separator or traversal, output resolves outside cwd, or an existing output file or directory is a symlink that resolves outside cwd',
|
|
84
84
|
},
|
|
85
85
|
{
|
|
86
86
|
code: 'ERR_UNKNOWN_COMPONENT',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* astryx --json swizzle [--list]
|
|
6
6
|
*/
|
|
7
7
|
export type SwizzleListResponse = {
|
|
8
8
|
type: "swizzle.list";
|
|
@@ -22,7 +22,7 @@ export type SwizzleFeedback = {
|
|
|
22
22
|
ghCommand?: string | undefined;
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
|
-
*
|
|
25
|
+
* astryx --json swizzle <component>
|
|
26
26
|
*/
|
|
27
27
|
export type SwizzleCopyResponse = {
|
|
28
28
|
type: "swizzle.copy";
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* astryx --json swizzle [--list]
|
|
11
11
|
*
|
|
12
12
|
* @typedef {object} SwizzleListResponse
|
|
13
13
|
* @property {'swizzle.list'} type
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* astryx --json swizzle <component>
|
|
27
27
|
*
|
|
28
28
|
* @typedef {object} SwizzleCopyResponse
|
|
29
29
|
* @property {'swizzle.copy'} type
|
|
@@ -36,13 +36,22 @@ export function templateCopy(match, {targetPath, cwd, overwrite = false}) {
|
|
|
36
36
|
);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
// If targetPath looks like a file (e.g. `./foo.tsx`), write directly to
|
|
40
|
+
// it. Previously this path was treated as a directory and the file was
|
|
41
|
+
// written as `./foo.tsx/page.tsx`, which is wrong and surprising.
|
|
42
|
+
const fileTarget = isFilePathArg(targetPath)
|
|
43
|
+
? targetPath
|
|
44
|
+
: path.join(
|
|
45
|
+
targetPath,
|
|
46
|
+
match.type === 'block' ? path.basename(match.filePath) : 'page.tsx',
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
// Path-safety: the guard sees the file that will be written, not only its
|
|
50
|
+
// directory — a symlink at that name would otherwise carry the write
|
|
51
|
+
// outside the project root. Runs BEFORE any mkdir/write.
|
|
52
|
+
let outputFilePath;
|
|
44
53
|
try {
|
|
45
|
-
|
|
54
|
+
outputFilePath = assertWithin(fileTarget, cwd, {
|
|
46
55
|
label: 'template target path',
|
|
47
56
|
});
|
|
48
57
|
} catch (err) {
|
|
@@ -55,23 +64,8 @@ export function templateCopy(match, {targetPath, cwd, overwrite = false}) {
|
|
|
55
64
|
}
|
|
56
65
|
throw err;
|
|
57
66
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// it. Previously this path was treated as a directory and the file was
|
|
61
|
-
// written as `./foo.tsx/page.tsx`, which is wrong and surprising.
|
|
62
|
-
let outputDir;
|
|
63
|
-
let outputFileName;
|
|
64
|
-
let outputFilePath;
|
|
65
|
-
if (isFilePathArg(targetPath)) {
|
|
66
|
-
outputDir = path.dirname(resolvedTarget);
|
|
67
|
-
outputFileName = path.basename(resolvedTarget);
|
|
68
|
-
outputFilePath = resolvedTarget;
|
|
69
|
-
} else {
|
|
70
|
-
outputDir = resolvedTarget;
|
|
71
|
-
outputFileName =
|
|
72
|
-
match.type === 'block' ? path.basename(match.filePath) : 'page.tsx';
|
|
73
|
-
outputFilePath = path.join(outputDir, outputFileName);
|
|
74
|
-
}
|
|
67
|
+
const outputDir = path.dirname(outputFilePath);
|
|
68
|
+
const outputFileName = path.basename(outputFilePath);
|
|
75
69
|
|
|
76
70
|
// Refuse to clobber an existing file unless the caller opts in. The CLI has
|
|
77
71
|
// its own pre-flight collision message, but the API is a public surface
|
|
@@ -48,4 +48,21 @@ describe('template.copy — overwrite + path safety', () => {
|
|
|
48
48
|
).rejects.toMatchObject({code: 'ERR_PATH_TRAVERSAL'});
|
|
49
49
|
expect(fs.existsSync(path.join(dir, '..', 'escape.tsx'))).toBe(false);
|
|
50
50
|
}, SLOW);
|
|
51
|
+
|
|
52
|
+
it('rejects a directory target whose page.tsx is a symlink leading outside cwd', async () => {
|
|
53
|
+
const outside = fs.mkdtempSync(path.join(os.tmpdir(), 'tmpl-copy-outside-'));
|
|
54
|
+
try {
|
|
55
|
+
const victim = path.join(outside, 'victim.tsx');
|
|
56
|
+
fs.writeFileSync(victim, 'OUTSIDE');
|
|
57
|
+
fs.mkdirSync(path.join(dir, 'dest'));
|
|
58
|
+
fs.symlinkSync(victim, path.join(dir, 'dest', 'page.tsx'));
|
|
59
|
+
|
|
60
|
+
await expect(
|
|
61
|
+
template('blank', {targetPath: './dest', overwrite: true, cwd: dir}),
|
|
62
|
+
).rejects.toMatchObject({code: 'ERR_PATH_TRAVERSAL'});
|
|
63
|
+
expect(fs.readFileSync(victim, 'utf-8')).toBe('OUTSIDE');
|
|
64
|
+
} finally {
|
|
65
|
+
fs.rmSync(outside, {recursive: true, force: true});
|
|
66
|
+
}
|
|
67
|
+
}, SLOW);
|
|
51
68
|
});
|
|
@@ -75,7 +75,8 @@ export const doc = {
|
|
|
75
75
|
name: 'options.targetPath',
|
|
76
76
|
type: 'string',
|
|
77
77
|
description:
|
|
78
|
-
'Destination (relative to cwd) to scaffold the template into. Its presence switches a named lookup into a copy.'
|
|
78
|
+
'Destination (relative to cwd) to scaffold the template into. Its presence switches a named lookup into a copy. ' +
|
|
79
|
+
'A path that ends in .tsx, .ts, .jsx, .js, .mjs, .cjs, .css, .scss, .json, .md or .html is the file to write; any other path is a directory, which receives page.tsx for a page template or the block\'s own file name for a block.',
|
|
79
80
|
},
|
|
80
81
|
{
|
|
81
82
|
name: 'options.overwrite',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* astryx --json template [--list]
|
|
6
6
|
*/
|
|
7
7
|
export type TemplateListResponse = {
|
|
8
8
|
type: "template.list";
|
|
@@ -53,7 +53,7 @@ export type TemplateListEntry = {
|
|
|
53
53
|
scaffold?: boolean | undefined;
|
|
54
54
|
};
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* astryx --json template <name>
|
|
57
57
|
*/
|
|
58
58
|
export type TemplateShowResponse = {
|
|
59
59
|
type: "template.show";
|
|
@@ -66,7 +66,7 @@ export type TemplateShowResponse = {
|
|
|
66
66
|
};
|
|
67
67
|
};
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
69
|
+
* astryx --json template <name> --skeleton
|
|
70
70
|
*/
|
|
71
71
|
export type TemplateSkeletonResponse = {
|
|
72
72
|
type: "template.skeleton";
|
|
@@ -78,7 +78,7 @@ export type TemplateSkeletonResponse = {
|
|
|
78
78
|
};
|
|
79
79
|
};
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
81
|
+
* astryx --json template <name> [path]
|
|
82
82
|
*/
|
|
83
83
|
export type TemplateCopyResponse = {
|
|
84
84
|
type: "template.copy";
|
|
@@ -90,7 +90,7 @@ export type TemplateCopyResponse = {
|
|
|
90
90
|
};
|
|
91
91
|
};
|
|
92
92
|
/**
|
|
93
|
-
*
|
|
93
|
+
* astryx --json template --cdn [path]
|
|
94
94
|
* `written: false` with `reason: 'exists'` is a success: the command is safe to
|
|
95
95
|
* re-run, and an edited page is the consumer's file to keep. `version` is the
|
|
96
96
|
* Astryx version every CDN URL in the file was pinned to.
|
|
@@ -6,18 +6,18 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Each template is exactly two files: page.tsx (code) + template.doc.mjs (metadata).
|
|
8
8
|
*
|
|
9
|
-
* Invocation
|
|
9
|
+
* Invocation -> type discriminator
|
|
10
10
|
* ------------------------------------------------------------------
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* (unknown template)
|
|
11
|
+
* astryx --json template [--list] -> template.list
|
|
12
|
+
* astryx --json template <name> -> template.show
|
|
13
|
+
* astryx --json template <name> --skeleton -> template.skeleton
|
|
14
|
+
* astryx --json template <name> [path] -> template.copy
|
|
15
|
+
* astryx --json template --cdn [path] -> template.cdn
|
|
16
|
+
* (unknown template) -> CLIError
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* astryx --json template [--list]
|
|
21
21
|
* @typedef {object} TemplateListResponse
|
|
22
22
|
* @property {'template.list'} type
|
|
23
23
|
* @property {TemplateListEntry[]} data
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
*/
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* astryx --json template <name>
|
|
47
47
|
* @typedef {object} TemplateShowResponse
|
|
48
48
|
* @property {'template.show'} type
|
|
49
49
|
* @property {object} data
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
*/
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
58
|
+
* astryx --json template <name> --skeleton
|
|
59
59
|
* @typedef {object} TemplateSkeletonResponse
|
|
60
60
|
* @property {'template.skeleton'} type
|
|
61
61
|
* @property {object} data
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
*/
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
69
|
+
* astryx --json template <name> [path]
|
|
70
70
|
* @typedef {object} TemplateCopyResponse
|
|
71
71
|
* @property {'template.copy'} type
|
|
72
72
|
* @property {object} data
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
*/
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
80
|
+
* astryx --json template --cdn [path]
|
|
81
81
|
* `written: false` with `reason: 'exists'` is a success: the command is safe to
|
|
82
82
|
* re-run, and an edited page is the consumer's file to keep. `version` is the
|
|
83
83
|
* Astryx version every CDN URL in the file was pinned to.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import {afterEach, beforeEach, describe, expect, it} from 'vitest';
|
|
4
|
+
import * as fs from 'node:fs';
|
|
5
|
+
import * as os from 'node:os';
|
|
6
|
+
import * as path from 'node:path';
|
|
7
|
+
import {themeAdd} from './add.mjs';
|
|
8
|
+
|
|
9
|
+
const HEADER = '// Copyright (c) Meta Platforms, Inc. and affiliates.\n\n';
|
|
10
|
+
|
|
11
|
+
let tmpDir;
|
|
12
|
+
|
|
13
|
+
/** Every byte value, so any lossy text decoding shows up as a changed file. */
|
|
14
|
+
const FONT_BYTES = Buffer.concat([
|
|
15
|
+
Buffer.from('wOF2'),
|
|
16
|
+
Buffer.from(Array.from({length: 256}, (_, byte) => byte)),
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
beforeEach(() => {
|
|
20
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-themeadd-binary-'));
|
|
21
|
+
fs.writeFileSync(
|
|
22
|
+
path.join(tmpDir, 'package.json'),
|
|
23
|
+
JSON.stringify({
|
|
24
|
+
name: 'consumer',
|
|
25
|
+
dependencies: {'@acme/themes': '^1.0.0'},
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
28
|
+
const packageDir = path.join(tmpDir, 'node_modules', '@acme', 'themes');
|
|
29
|
+
const themeDir = path.join(packageDir, 'themes', 'ocean');
|
|
30
|
+
fs.mkdirSync(path.join(themeDir, 'fonts'), {recursive: true});
|
|
31
|
+
fs.writeFileSync(
|
|
32
|
+
path.join(packageDir, 'package.json'),
|
|
33
|
+
JSON.stringify({name: '@acme/themes', version: '1.0.0'}),
|
|
34
|
+
);
|
|
35
|
+
fs.writeFileSync(
|
|
36
|
+
path.join(packageDir, 'astryx.integration.mjs'),
|
|
37
|
+
"export default {themes: './themes'};\n",
|
|
38
|
+
);
|
|
39
|
+
fs.writeFileSync(
|
|
40
|
+
path.join(packageDir, 'themes', 'manifest.json'),
|
|
41
|
+
JSON.stringify({
|
|
42
|
+
version: 1,
|
|
43
|
+
themes: [
|
|
44
|
+
{
|
|
45
|
+
slug: 'ocean',
|
|
46
|
+
displayName: 'Ocean',
|
|
47
|
+
description: 'Integration theme that ships a font.',
|
|
48
|
+
maintained: true,
|
|
49
|
+
entry: 'oceanTheme.ts',
|
|
50
|
+
exportName: 'oceanTheme',
|
|
51
|
+
files: ['oceanTheme.ts', 'fonts/ocean.woff2'],
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
fs.writeFileSync(
|
|
57
|
+
path.join(themeDir, 'oceanTheme.ts'),
|
|
58
|
+
`${HEADER}export const oceanTheme = {};\n`,
|
|
59
|
+
);
|
|
60
|
+
fs.writeFileSync(path.join(themeDir, 'fonts', 'ocean.woff2'), FONT_BYTES);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
afterEach(() => {
|
|
64
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('themeAdd copies every listed file', () => {
|
|
68
|
+
it('copies a binary file byte for byte', async () => {
|
|
69
|
+
const result = await themeAdd('ocean', {
|
|
70
|
+
cwd: tmpDir,
|
|
71
|
+
package: '@acme/themes',
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
expect(result.data.files).toEqual(['oceanTheme.ts', 'fonts/ocean.woff2']);
|
|
75
|
+
const copied = fs.readFileSync(
|
|
76
|
+
path.join(tmpDir, 'src', 'themes', 'ocean', 'fonts', 'ocean.woff2'),
|
|
77
|
+
);
|
|
78
|
+
expect(copied.equals(FONT_BYTES)).toBe(true);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('still strips the repo header from a text source', async () => {
|
|
82
|
+
await themeAdd('ocean', {cwd: tmpDir, package: '@acme/themes'});
|
|
83
|
+
|
|
84
|
+
expect(
|
|
85
|
+
fs.readFileSync(
|
|
86
|
+
path.join(tmpDir, 'src', 'themes', 'ocean', 'oceanTheme.ts'),
|
|
87
|
+
'utf-8',
|
|
88
|
+
),
|
|
89
|
+
).toBe('export const oceanTheme = {};\n');
|
|
90
|
+
});
|
|
91
|
+
});
|
package/api/theme/add/add.mjs
CHANGED
|
@@ -26,6 +26,20 @@ function defaultTargetDir(slug) {
|
|
|
26
26
|
return path.join('src', 'themes', slug);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* The bytes to write for one listed file. Only UTF-8 text loses our header;
|
|
31
|
+
* anything else (a font, an image) is copied verbatim, since decoding it would
|
|
32
|
+
* corrupt it.
|
|
33
|
+
* @param {Buffer} bytes
|
|
34
|
+
* @returns {Buffer | string}
|
|
35
|
+
*/
|
|
36
|
+
function scaffoldContents(bytes) {
|
|
37
|
+
const text = bytes.toString('utf-8');
|
|
38
|
+
return Buffer.from(text, 'utf-8').equals(bytes)
|
|
39
|
+
? stripCopyrightHeader(text)
|
|
40
|
+
: bytes;
|
|
41
|
+
}
|
|
42
|
+
|
|
29
43
|
/**
|
|
30
44
|
* Copy a bundled theme's files into the consumer's project (defaults to
|
|
31
45
|
* `src/themes/<slug>/`). Writes are staged to temp files then renamed, rolling
|
|
@@ -135,8 +149,7 @@ export async function themeAdd(slug, options = {}) {
|
|
|
135
149
|
});
|
|
136
150
|
fs.mkdirSync(path.dirname(dest), {recursive: true});
|
|
137
151
|
const tmp = `${dest}.${process.pid}.tmp`;
|
|
138
|
-
|
|
139
|
-
fs.writeFileSync(tmp, contents);
|
|
152
|
+
fs.writeFileSync(tmp, scaffoldContents(fs.readFileSync(w.src)));
|
|
140
153
|
staged.push({tmp, dest});
|
|
141
154
|
}
|
|
142
155
|
for (const s of staged) {
|