@astryxdesign/cli 0.7.2-canary.ab79547 → 0.7.2-canary.b40ba52
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 +20 -19
- package/api/build/help/help.mjs +1 -1
- package/api/component/_adapter.d.mts +41 -1
- package/api/component/_adapter.mjs +93 -7
- package/api/component/component.mjs +22 -5
- package/api/component/integration-export-name.test.mjs +644 -0
- package/api/discover/_adapter.d.mts +119 -12
- package/api/discover/_adapter.mjs +449 -10
- package/api/discover/_adapter.test.mjs +599 -17
- package/api/discover/_catalog-view.d.mts +16 -5
- package/api/discover/_catalog-view.mjs +32 -8
- package/api/discover/discover.d.mts +11 -0
- package/api/discover/discover.doc.mjs +7 -6
- package/api/discover/discover.mjs +107 -19
- package/api/discover/discover.type.d.mts +18 -7
- package/api/discover/discover.type.mjs +15 -7
- package/api/discover/list/list.d.mts +4 -3
- package/api/discover/list/list.mjs +17 -10
- package/api/docs/_adapter.d.mts +11 -0
- package/api/docs/_adapter.mjs +244 -1
- package/api/docs/integrationDocs.test.mjs +124 -0
- package/api/doctor/doctor.mjs +27 -3
- package/api/doctor/doctor.test.mjs +43 -0
- package/api/doctor/theme-checks.mjs +1 -1
- package/api/doctor/theme-checks.test.mjs +136 -0
- package/api/gap-report/gap-report.d.mts +3 -0
- package/api/gap-report/gap-report.doc.mjs +11 -3
- package/api/gap-report/gap-report.mjs +219 -52
- package/api/gap-report/gap-report.test.mjs +233 -0
- package/api/gap-report/gap-report.type.d.mts +41 -0
- package/api/gap-report/gap-report.type.mjs +18 -0
- package/api/index.d.mts +2 -0
- package/api/index.mjs +2 -0
- package/api/init/run/run.mjs +2 -2
- package/api/integration/_adapter.d.mts +12 -0
- package/api/integration/_adapter.mjs +54 -0
- package/api/integration/add-contribution.component-names.test.mjs +66 -0
- package/api/integration/add-contribution.mjs +8 -4
- package/api/integration/add-contribution.test.mjs +4 -2
- package/api/integration/authoring-checks.mjs +11 -2
- package/api/integration/authoring-checks.test.mjs +39 -0
- package/api/integration/authoring-checks.type.d.mts +9 -0
- package/api/integration/authoring-checks.type.mjs +14 -1
- package/api/integration/check/check.d.mts +96 -0
- package/api/integration/check/check.mjs +357 -0
- package/api/integration/check/check.test.mjs +489 -0
- package/api/integration/integration-check.type.d.mts +118 -0
- package/api/integration/integration-check.type.mjs +84 -0
- package/api/integration/integrationCheck.doc.d.mts +10 -0
- package/api/integration/integrationCheck.doc.mjs +73 -0
- package/api/integration/integrationComponentConflicts.doc.mjs +43 -6
- package/api/integration/pack-check.mjs +343 -104
- package/api/integration/pack-check.test.mjs +700 -0
- package/api/integration/validate-integration.mjs +8 -0
- package/api/integration/validate-integration.test.mjs +11 -0
- package/api/integration/validate-integration.type.d.mts +8 -0
- package/api/integration/validate-integration.type.mjs +12 -1
- package/api/integration/validateIntegration.doc.mjs +19 -3
- package/api/search/search.d.mts +81 -12
- package/api/search/search.domain-priority.test.mjs +108 -18
- package/api/search/search.integration-check.test.mjs +24 -0
- package/api/search/search.mjs +601 -50
- package/api/search/search.test.mjs +139 -0
- package/api/swizzle/copy/copy.mjs +28 -14
- package/api/theme/build/build.family.test.mjs +54 -6
- package/api/theme/build/build.mjs +114 -17
- package/api/theme/themeBuild.doc.mjs +4 -4
- package/api/upgrade/_adapter.d.mts +40 -2
- package/api/upgrade/_adapter.mjs +117 -4
- package/api/upgrade/run/cli-behind-core.test.mjs +438 -0
- package/api/upgrade/run/run.mjs +30 -1
- package/api/upgrade/status/status.d.mts +21 -5
- package/api/upgrade/status/status.mjs +45 -8
- package/api/upgrade/upgrade.doc.mjs +5 -3
- package/api/upgrade/upgrade.type.d.mts +23 -0
- package/api/upgrade/upgrade.type.mjs +16 -1
- package/assets/codemods/runner.mjs +7 -1
- package/assets/discover/official-packages.json +367 -0
- package/assets/docs/README.md +10 -0
- package/assets/docs/author-a-theme.doc.mjs +1 -1
- package/assets/docs/getting-started.doc.mjs +3 -3
- package/assets/docs/styling-overview.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +1 -1
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/docs/tree/add-a-component.doc.mjs +11 -1
- package/assets/docs/tree/add-a-theme.doc.mjs +1 -1
- package/assets/docs/tree/add-a-topic.doc.mjs +10 -7
- package/assets/docs/tree/agent-guidance.doc.mjs +2 -2
- package/assets/docs/tree/block-template.doc.mjs +8 -20
- package/assets/docs/tree/build-the-template.doc.mjs +1 -1
- package/assets/docs/tree/check-the-props.doc.mjs +196 -0
- package/assets/docs/tree/check-your-docs.doc.mjs +51 -5
- package/assets/docs/tree/checks.doc.mjs +24 -16
- package/assets/docs/tree/codemods.doc.mjs +4 -4
- package/assets/docs/tree/component-family.doc.mjs +8 -6
- package/assets/docs/tree/component-imports.doc.mjs +10 -2
- package/assets/docs/tree/components.doc.mjs +1 -1
- package/assets/docs/tree/debug-and-gap-reports.doc.mjs +25 -16
- package/assets/docs/tree/define-the-theme.doc.mjs +6 -5
- package/assets/docs/tree/describe-the-component.doc.mjs +2 -2
- package/assets/docs/tree/docs.doc.mjs +3 -3
- package/assets/docs/tree/document-the-template.doc.mjs +1 -1
- package/assets/docs/tree/document-the-theme.doc.mjs +1 -1
- package/assets/docs/tree/export-template-assets.doc.mjs +1 -1
- package/assets/docs/tree/extend-or-replace.doc.mjs +6 -6
- package/assets/docs/tree/fonts-and-assets.doc.mjs +2 -2
- package/assets/docs/tree/generate-a-palette.doc.mjs +5 -3
- package/assets/docs/tree/grade-template-with-agent.doc.mjs +1 -1
- package/assets/docs/tree/integrations.doc.mjs +8 -0
- package/assets/docs/tree/links.doc.mjs +6 -5
- package/assets/docs/tree/migration-setup.doc.mjs +1 -0
- package/assets/docs/tree/migration-verification.doc.mjs +0 -1
- package/assets/docs/tree/migration.doc.mjs +0 -1
- package/assets/docs/tree/package-and-test.doc.mjs +1 -1
- package/assets/docs/tree/page-template.doc.mjs +4 -8
- package/assets/docs/tree/publishing.doc.mjs +1 -1
- package/assets/docs/tree/quick-start.doc.mjs +37 -21
- package/assets/docs/tree/replace-a-core-component.doc.mjs +4 -6
- package/assets/docs/tree/replace-a-core-template.doc.mjs +6 -8
- package/assets/docs/tree/sections-and-placement.doc.mjs +4 -6
- package/assets/docs/tree/see-it-in-an-app.doc.mjs +4 -2
- package/assets/docs/tree/short-and-findable.doc.mjs +6 -5
- package/assets/docs/tree/single-component.doc.mjs +15 -6
- package/assets/docs/tree/start-a-template.doc.mjs +3 -3
- package/assets/docs/tree/subcomponent.doc.mjs +6 -6
- package/assets/docs/tree/template-assets.doc.mjs +2 -2
- package/assets/docs/tree/template-doc-overview.doc.mjs +4 -15
- package/assets/docs/tree/template-fonts.doc.mjs +1 -1
- package/assets/docs/tree/template-icons.doc.mjs +1 -1
- package/assets/docs/tree/template-images-media.doc.mjs +1 -1
- package/assets/docs/tree/template-styles.doc.mjs +2 -2
- package/assets/docs/tree/templates.doc.mjs +1 -1
- package/assets/docs/tree/test-in-an-app.doc.mjs +3 -3
- package/assets/docs/tree/test-template-in-app.doc.mjs +1 -1
- package/assets/docs/tree/tokens-and-setup.doc.mjs +19 -15
- package/assets/docs/tree/troubleshooting.doc.mjs +13 -5
- package/assets/docs/tree/type-scale.doc.mjs +3 -3
- package/assets/docs/tree/upgrading.doc.mjs +3 -3
- package/assets/docs/tree/use-a-theme-in-an-app.doc.mjs +3 -1
- package/assets/docs/tree/verify-packed-template.doc.mjs +1 -1
- package/assets/docs/tree/versioning.doc.mjs +7 -6
- package/assets/docs/tree/write-the-template-file.doc.mjs +4 -3
- package/assets/docs/use-a-theme.doc.mjs +2 -2
- package/assets/theme.template.ts +1 -1
- package/authoring/codemod/codemod.doc.mjs +7 -3
- package/authoring/config/config.doc.mjs +9 -6
- package/authoring/config/type.ts +4 -2
- package/authoring/discover/discover.doc.mjs +1 -1
- package/authoring/doctypes/base/graph-fields.doc.mjs +6 -4
- package/authoring/doctypes/command/command.doc.mjs +14 -12
- package/authoring/doctypes/component/component.doc.mjs +29 -26
- package/authoring/doctypes/component/type.ts +13 -8
- package/authoring/doctypes/enum/enum.doc.mjs +7 -4
- package/authoring/doctypes/function/function.doc.mjs +9 -8
- package/authoring/doctypes/hook/hook.doc.mjs +5 -4
- package/authoring/doctypes/namespace/namespace.doc.mjs +7 -6
- package/authoring/doctypes/reference/reference.doc.mjs +11 -10
- package/authoring/doctypes/schema/schema.doc.mjs +9 -9
- package/authoring/doctypes/template/integration-template.doc.d.mts +11 -0
- package/authoring/doctypes/template/integration-template.doc.mjs +49 -0
- package/authoring/doctypes/template/parse.d.mts +6 -2
- package/authoring/doctypes/template/parse.mjs +3 -1
- package/authoring/doctypes/template/template.doc.mjs +3 -3
- package/authoring/doctypes/template/type.ts +22 -0
- package/authoring/doctypes/theme/theme.doc.mjs +2 -2
- package/authoring/gap-report/gap-report.doc.mjs +2 -2
- package/authoring/identity/identity.doc.mjs +3 -3
- package/authoring/index.d.ts +1 -0
- package/authoring/integration/integration.doc.mjs +12 -4
- package/authoring/integration/parse.test.mjs +10 -0
- package/authoring/integration/schema.d.mts +2 -0
- package/authoring/integration/schema.mjs +1 -0
- package/authoring/integration/type.ts +4 -0
- package/clients/cli/commands/build-theme.batch-report.test.mjs +3 -1
- package/clients/cli/commands/build-theme.mjs +1 -1
- package/clients/cli/commands/build-theme.path-safety.test.mjs +155 -21
- package/clients/cli/commands/cli-postinstall.test.mjs +49 -1
- package/clients/cli/commands/discover.broken-integration.test.mjs +4 -1
- package/clients/cli/commands/discover.doc.mjs +1 -1
- package/clients/cli/commands/discover.mjs +144 -93
- package/clients/cli/commands/discover.no-source.test.mjs +447 -33
- package/clients/cli/commands/discover.sources.test.mjs +20 -1
- package/clients/cli/commands/doctor-integration-components.doc.mjs +17 -4
- package/clients/cli/commands/doctor-integration-validate.doc.mjs +13 -2
- package/clients/cli/commands/doctor-integration.test.mjs +837 -0
- package/clients/cli/commands/doctor.mjs +190 -0
- package/clients/cli/commands/gap-report.doc.mjs +14 -2
- package/clients/cli/commands/gap-report.mjs +24 -2
- package/clients/cli/commands/gap-report.test.mjs +79 -0
- package/clients/cli/commands/integration-check.doc.mjs +85 -0
- package/clients/cli/commands/integration-check.test.mjs +284 -0
- package/clients/cli/commands/integration.doc.mjs +6 -2
- package/clients/cli/commands/integration.mjs +106 -1
- package/clients/cli/commands/json-contract.test.mjs +5 -1
- package/clients/cli/commands/setup-nudge.test.mjs +79 -1
- package/clients/cli/commands/swizzle.mjs +5 -3
- package/clients/cli/commands/swizzle.routing.test.mjs +18 -1
- package/clients/cli/commands/text-json-parity.test.mjs +5 -0
- package/clients/cli/commands/theme-build.doc.mjs +2 -2
- package/clients/cli/commands/upgrade.doc.mjs +14 -0
- package/clients/cli/commands/upgrade.older-cli.test.mjs +160 -0
- package/clients/cli/index.mjs +30 -5
- package/foundation/agent-docs/agent-doc-state.d.mts +14 -0
- package/foundation/agent-docs/agent-doc-state.mjs +38 -0
- package/foundation/agent-docs/agent-docs.d.mts +2 -1
- package/foundation/agent-docs/agent-docs.mjs +8 -6
- package/foundation/config/project.mjs +82 -0
- package/foundation/discovery/authoring-self-docs.mjs +2 -1
- package/foundation/discovery/component-discovery.d.mts +178 -10
- package/foundation/discovery/component-discovery.export-names.test.mjs +760 -0
- package/foundation/discovery/component-discovery.mjs +659 -62
- package/foundation/discovery/component-replacement.mjs +18 -0
- package/foundation/discovery/component-replacement.test.mjs +40 -0
- package/foundation/discovery/doc-types.d.mts +157 -0
- package/foundation/discovery/doc-types.mjs +1224 -0
- package/foundation/discovery/doc-types.test.mjs +700 -0
- package/foundation/discovery/docs-discovery.d.mts +81 -0
- package/foundation/discovery/docs-discovery.mjs +57 -0
- package/foundation/discovery/integration-doc-files.d.mts +22 -0
- package/foundation/discovery/integration-doc-files.mjs +231 -0
- package/foundation/discovery/integration-doc-files.test.mjs +246 -0
- package/foundation/discovery/module-exports.d.mts +27 -0
- package/foundation/discovery/module-exports.mjs +356 -31
- package/foundation/discovery/module-exports.test.mjs +172 -0
- package/foundation/discovery/package-tsconfig.d.mts +14 -0
- package/foundation/discovery/package-tsconfig.mjs +228 -0
- package/foundation/discovery/package-tsconfig.test.mjs +210 -0
- package/foundation/discovery/project-typescript.d.mts +32 -0
- package/foundation/discovery/project-typescript.mjs +89 -0
- package/foundation/discovery/prop-drift.d.mts +278 -0
- package/foundation/discovery/prop-drift.mjs +2263 -0
- package/foundation/discovery/prop-drift.test.mjs +2272 -0
- package/foundation/discovery/type-match.d.mts +53 -0
- package/foundation/discovery/type-match.mjs +660 -0
- package/foundation/discovery/type-match.test.mjs +169 -0
- package/foundation/discovery/type-text.d.mts +68 -0
- package/foundation/discovery/type-text.mjs +658 -0
- package/foundation/discovery/type-text.test.mjs +196 -0
- package/foundation/discovery/unresolved-references.d.mts +62 -0
- package/foundation/discovery/unresolved-references.mjs +790 -0
- package/foundation/discovery/unresolved-references.test.mjs +567 -0
- package/foundation/doc-compiler/doc-loads.test.mjs +10 -0
- package/foundation/doc-compiler/links.d.mts +9 -5
- package/foundation/doc-compiler/links.mjs +4 -2
- package/foundation/env/package-manager.d.mts +32 -0
- package/foundation/env/package-manager.mjs +47 -0
- package/foundation/env/package-manager.test.mjs +194 -7
- package/foundation/fs/module-loader.d.mts +2 -1
- package/foundation/fs/module-loader.mjs +60 -4
- package/foundation/fs/module-loader.test.mjs +194 -0
- package/foundation/integrations/contribution-inventory.mjs +6 -1
- package/foundation/response/response-types.doc.mjs +13 -7
- package/package.json +9 -9
- package/scripts/postinstall.mjs +3 -3
|
@@ -1,16 +1,32 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file Tests for how the discover adapter
|
|
5
|
-
* failure isolation, timeouts, and the saved copy
|
|
6
|
-
*
|
|
4
|
+
* @file Tests for how the discover adapter reads the official list and calls
|
|
5
|
+
* discover sources: order, failure isolation, timeouts, and the saved copy,
|
|
6
|
+
* plus what the official list adds to the installed list and the add command.
|
|
7
|
+
* Sources are plain functions on a stand-in project, and the saved copies go
|
|
8
|
+
* to a temp directory.
|
|
7
9
|
*/
|
|
8
10
|
|
|
9
11
|
import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest';
|
|
10
12
|
import * as fs from 'node:fs';
|
|
11
13
|
import * as os from 'node:os';
|
|
12
14
|
import * as path from 'node:path';
|
|
13
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
addCommand,
|
|
17
|
+
callSources,
|
|
18
|
+
OFFICIAL_LIST_FILE,
|
|
19
|
+
officialDeclarations,
|
|
20
|
+
officialList,
|
|
21
|
+
withDeclaredOfficial,
|
|
22
|
+
} from './_adapter.mjs';
|
|
23
|
+
import {parseDiscoverCatalog} from '../../authoring/discover/parse.mjs';
|
|
24
|
+
|
|
25
|
+
/** No official packages, so a test sees only its own sources after it. */
|
|
26
|
+
const NO_OFFICIAL = {packages: []};
|
|
27
|
+
|
|
28
|
+
/** How the official list reports itself among the sources. */
|
|
29
|
+
const OFFICIAL_STATE = ['Astryx', '@astryxdesign/cli', 'fresh'];
|
|
14
30
|
|
|
15
31
|
/**
|
|
16
32
|
* @param {string} name
|
|
@@ -43,11 +59,28 @@ function pkg(name, extra = {}) {
|
|
|
43
59
|
}
|
|
44
60
|
|
|
45
61
|
/**
|
|
46
|
-
* @param {{config?: object, integrations?: object[]}} parts
|
|
62
|
+
* @param {{config?: object, integrations?: object[], cwd?: string}} parts
|
|
47
63
|
* @returns {any}
|
|
48
64
|
*/
|
|
49
|
-
function project({config = {}, integrations = []}) {
|
|
50
|
-
return {config, loadedIntegrations: integrations, cwd
|
|
65
|
+
function project({config = {}, integrations = [], cwd = '/virtual/project'}) {
|
|
66
|
+
return {config, loadedIntegrations: integrations, cwd};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* An official package as officialList() returns it.
|
|
71
|
+
* @param {string} name
|
|
72
|
+
* @param {object} [extra]
|
|
73
|
+
*/
|
|
74
|
+
function official(name, extra = {}) {
|
|
75
|
+
return {
|
|
76
|
+
...pkg(name, {latest: '0.7.1'}),
|
|
77
|
+
versions: [
|
|
78
|
+
{version: '0.7.1', publishedAt: null, prerelease: false, status: 'ok'},
|
|
79
|
+
],
|
|
80
|
+
contributions: [{kind: 'theme', name: name.split('-').pop()}],
|
|
81
|
+
pin: '0.7.1',
|
|
82
|
+
...extra,
|
|
83
|
+
};
|
|
51
84
|
}
|
|
52
85
|
|
|
53
86
|
let cacheDir;
|
|
@@ -82,13 +115,14 @@ describe('callSources', () => {
|
|
|
82
115
|
],
|
|
83
116
|
}),
|
|
84
117
|
{},
|
|
85
|
-
{cacheDir},
|
|
118
|
+
{cacheDir, official: NO_OFFICIAL},
|
|
86
119
|
);
|
|
87
120
|
|
|
88
121
|
expect(calls).toEqual(['own', 'shared']);
|
|
89
122
|
expect(result.sources.map(s => [s.name, s.from, s.status])).toEqual([
|
|
90
123
|
['Own', 'astryx.config', 'fresh'],
|
|
91
124
|
['Shared', '@x/first', 'fresh'],
|
|
125
|
+
OFFICIAL_STATE,
|
|
92
126
|
]);
|
|
93
127
|
expect(result.packages.map(p => [p.package, p.latest, p.source])).toEqual([
|
|
94
128
|
['@a/one', '9.9.9', 'Own'],
|
|
@@ -102,7 +136,7 @@ describe('callSources', () => {
|
|
|
102
136
|
await callSources(
|
|
103
137
|
project({integrations: [{name: '@x/src', __discover: source}]}),
|
|
104
138
|
{package: '@a/one', version: '1.0.0'},
|
|
105
|
-
{cacheDir},
|
|
139
|
+
{cacheDir, official: NO_OFFICIAL},
|
|
106
140
|
);
|
|
107
141
|
|
|
108
142
|
expect(source).toHaveBeenCalledWith({
|
|
@@ -134,7 +168,7 @@ describe('callSources', () => {
|
|
|
134
168
|
],
|
|
135
169
|
}),
|
|
136
170
|
{},
|
|
137
|
-
{cacheDir},
|
|
171
|
+
{cacheDir, official: NO_OFFICIAL},
|
|
138
172
|
);
|
|
139
173
|
|
|
140
174
|
expect(result.sources.map(s => [s.from, s.status])).toEqual([
|
|
@@ -142,6 +176,7 @@ describe('callSources', () => {
|
|
|
142
176
|
['@x/bad', 'failed'],
|
|
143
177
|
['@x/broken', 'failed'],
|
|
144
178
|
['@x/good', 'fresh'],
|
|
179
|
+
['@astryxdesign/cli', 'fresh'],
|
|
145
180
|
]);
|
|
146
181
|
expect(result.sources[0].error).toContain('offline');
|
|
147
182
|
expect(result.sources[1].error).toContain('schemaVersion 2');
|
|
@@ -160,7 +195,7 @@ describe('callSources', () => {
|
|
|
160
195
|
const result = await callSources(
|
|
161
196
|
project({integrations: [{name: '@x/slow', __discover: slow}]}),
|
|
162
197
|
{},
|
|
163
|
-
{cacheDir, timeoutMs: 20},
|
|
198
|
+
{cacheDir, timeoutMs: 20, official: NO_OFFICIAL},
|
|
164
199
|
);
|
|
165
200
|
|
|
166
201
|
expect(result.sources[0]).toMatchObject({
|
|
@@ -177,10 +212,11 @@ describe('callSources', () => {
|
|
|
177
212
|
return catalog('S', [pkg('@a/one')]);
|
|
178
213
|
};
|
|
179
214
|
const p = project({integrations: [{name: '@x/src', __discover: source}]});
|
|
215
|
+
const options = {cacheDir, official: NO_OFFICIAL};
|
|
180
216
|
|
|
181
|
-
await callSources(p, {},
|
|
217
|
+
await callSources(p, {}, options);
|
|
182
218
|
online = false;
|
|
183
|
-
const offline = await callSources(p, {},
|
|
219
|
+
const offline = await callSources(p, {}, options);
|
|
184
220
|
|
|
185
221
|
expect(offline.sources[0]).toMatchObject({
|
|
186
222
|
name: 'S',
|
|
@@ -190,7 +226,7 @@ describe('callSources', () => {
|
|
|
190
226
|
});
|
|
191
227
|
expect(offline.packages.map(x => x.package)).toEqual(['@a/one']);
|
|
192
228
|
|
|
193
|
-
const otherRequest = await callSources(p, {package: '@a/one'},
|
|
229
|
+
const otherRequest = await callSources(p, {package: '@a/one'}, options);
|
|
194
230
|
expect(otherRequest.sources[0].status).toBe('failed');
|
|
195
231
|
});
|
|
196
232
|
|
|
@@ -202,14 +238,560 @@ describe('callSources', () => {
|
|
|
202
238
|
],
|
|
203
239
|
}),
|
|
204
240
|
{},
|
|
205
|
-
{cacheDir},
|
|
241
|
+
{cacheDir, official: NO_OFFICIAL},
|
|
206
242
|
);
|
|
207
243
|
|
|
208
244
|
expect(fs.readdirSync(path.join(cacheDir, 'discover'))).toHaveLength(1);
|
|
209
245
|
expect(fs.existsSync('/virtual/project')).toBe(false);
|
|
210
246
|
});
|
|
211
247
|
|
|
212
|
-
it('returns
|
|
213
|
-
|
|
248
|
+
it('returns only the official list when there is no project', async () => {
|
|
249
|
+
const result = await callSources(
|
|
250
|
+
undefined,
|
|
251
|
+
{},
|
|
252
|
+
{official: {packages: [official('@astryxdesign/theme-gothic')]}},
|
|
253
|
+
);
|
|
254
|
+
expect(result.sources.map(s => [s.name, s.from, s.status])).toEqual([
|
|
255
|
+
OFFICIAL_STATE,
|
|
256
|
+
]);
|
|
257
|
+
expect(result.packages.map(p => [p.package, p.source])).toEqual([
|
|
258
|
+
['@astryxdesign/theme-gothic', 'Astryx'],
|
|
259
|
+
]);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('reads the official list last, so another source keeps its entry', async () => {
|
|
263
|
+
const own = async () =>
|
|
264
|
+
catalog('Own', [
|
|
265
|
+
pkg('@a/two'),
|
|
266
|
+
pkg('@astryxdesign/theme-matcha', {latest: '0.6.8'}),
|
|
267
|
+
]);
|
|
268
|
+
const result = await callSources(
|
|
269
|
+
project({config: {discover: own}}),
|
|
270
|
+
{},
|
|
271
|
+
{
|
|
272
|
+
cacheDir,
|
|
273
|
+
official: {
|
|
274
|
+
packages: [
|
|
275
|
+
official('@astryxdesign/theme-gothic'),
|
|
276
|
+
official('@astryxdesign/theme-matcha'),
|
|
277
|
+
],
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
expect(result.sources.map(s => [s.name, s.from, s.status])).toEqual([
|
|
283
|
+
['Own', 'astryx.config', 'fresh'],
|
|
284
|
+
OFFICIAL_STATE,
|
|
285
|
+
]);
|
|
286
|
+
// The add command's pin stays with the list; a catalog entry never
|
|
287
|
+
// carries it.
|
|
288
|
+
for (const entry of result.packages)
|
|
289
|
+
expect(entry).not.toHaveProperty('pin');
|
|
290
|
+
// Source order: discover puts official packages first only where it
|
|
291
|
+
// shows them.
|
|
292
|
+
expect(
|
|
293
|
+
result.packages.map(p => [p.package, p.latest, p.source, !!p.official]),
|
|
294
|
+
).toEqual([
|
|
295
|
+
['@a/two', '1.0.0', 'Own', false],
|
|
296
|
+
['@astryxdesign/theme-matcha', '0.6.8', 'Own', false],
|
|
297
|
+
['@astryxdesign/theme-gothic', '0.7.1', 'Astryx', true],
|
|
298
|
+
]);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
it('keeps a source’s package for an official integration it publishes under another name', async () => {
|
|
302
|
+
const own = async () =>
|
|
303
|
+
catalog('Own', [
|
|
304
|
+
pkg('@acme/gothic-fork', {
|
|
305
|
+
integration: '@astryxdesign/theme-gothic',
|
|
306
|
+
contributions: [{kind: 'theme', name: 'gothic'}],
|
|
307
|
+
}),
|
|
308
|
+
pkg('@acme/stone-mirror', {aliases: ['@astryxdesign/theme-stone']}),
|
|
309
|
+
]);
|
|
310
|
+
const result = await callSources(
|
|
311
|
+
project({config: {discover: own}}),
|
|
312
|
+
{},
|
|
313
|
+
{
|
|
314
|
+
cacheDir,
|
|
315
|
+
official: {
|
|
316
|
+
packages: [
|
|
317
|
+
official('@astryxdesign/theme-gothic'),
|
|
318
|
+
official('@astryxdesign/theme-stone'),
|
|
319
|
+
official('@astryxdesign/theme-matcha'),
|
|
320
|
+
],
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
);
|
|
324
|
+
expect(result.packages.map(p => [p.package, p.source])).toEqual([
|
|
325
|
+
['@acme/gothic-fork', 'Own'],
|
|
326
|
+
['@acme/stone-mirror', 'Own'],
|
|
327
|
+
['@astryxdesign/theme-matcha', 'Astryx'],
|
|
328
|
+
]);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it('answers a package request with only that official package', async () => {
|
|
332
|
+
const result = await callSources(
|
|
333
|
+
project({}),
|
|
334
|
+
{package: '@astryxdesign/theme-matcha'},
|
|
335
|
+
{
|
|
336
|
+
cacheDir,
|
|
337
|
+
official: {
|
|
338
|
+
packages: [
|
|
339
|
+
official('@astryxdesign/theme-gothic'),
|
|
340
|
+
official('@astryxdesign/theme-matcha'),
|
|
341
|
+
],
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
);
|
|
345
|
+
expect(result.packages.map(p => p.package)).toEqual([
|
|
346
|
+
'@astryxdesign/theme-matcha',
|
|
347
|
+
]);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it('reports an official list it could not read like a failed source', async () => {
|
|
351
|
+
const result = await callSources(
|
|
352
|
+
project({}),
|
|
353
|
+
{},
|
|
354
|
+
{cacheDir, official: {packages: [], error: 'the list is missing'}},
|
|
355
|
+
);
|
|
356
|
+
expect(result.sources.slice(-1)).toEqual([
|
|
357
|
+
{
|
|
358
|
+
name: 'Astryx',
|
|
359
|
+
from: '@astryxdesign/cli',
|
|
360
|
+
status: 'failed',
|
|
361
|
+
error: 'the list is missing',
|
|
362
|
+
},
|
|
363
|
+
]);
|
|
364
|
+
expect(result.packages).toEqual([]);
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* A stand-in project folder whose installed Core is `version`.
|
|
370
|
+
* @param {string} dir
|
|
371
|
+
* @param {string} version
|
|
372
|
+
*/
|
|
373
|
+
function withCore(dir, version) {
|
|
374
|
+
const at = path.join(dir, 'node_modules', '@astryxdesign', 'core');
|
|
375
|
+
fs.mkdirSync(at, {recursive: true});
|
|
376
|
+
fs.writeFileSync(
|
|
377
|
+
path.join(at, 'package.json'),
|
|
378
|
+
JSON.stringify({name: '@astryxdesign/core', version}),
|
|
379
|
+
);
|
|
380
|
+
return project({cwd: dir});
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/** The version an entry lists, with its latest. */
|
|
384
|
+
const versionsOf = (
|
|
385
|
+
/** @type {{latest: string | null, versions: {version: string, prerelease: boolean}[]} | undefined} */ entry,
|
|
386
|
+
) =>
|
|
387
|
+
entry && {
|
|
388
|
+
latest: entry.latest,
|
|
389
|
+
versions: entry.versions.map(v => [v.version, v.prerelease]),
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
/** @param {{package: string}[]} packages @param {string} name */
|
|
393
|
+
const find = (packages, name) => packages.find(p => p.package === name);
|
|
394
|
+
|
|
395
|
+
const NEUTRAL = '@astryxdesign/theme-neutral';
|
|
396
|
+
|
|
397
|
+
/** The canary-only package names in the committed list. */
|
|
398
|
+
function canaryOnlyNames() {
|
|
399
|
+
return JSON.parse(fs.readFileSync(OFFICIAL_LIST_FILE, 'utf8'))
|
|
400
|
+
.packages.filter((/** @type {{canaryOnly?: boolean}} */ p) => p.canaryOnly)
|
|
401
|
+
.map((/** @type {{package: string}} */ p) => p.package);
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
describe('officialList', () => {
|
|
405
|
+
it('gives every official package the release CLI’s version when the project has no Core', () => {
|
|
406
|
+
const {packages, error} = officialList({version: '0.7.1'});
|
|
407
|
+
expect(error).toBeUndefined();
|
|
408
|
+
expect(packages.length).toBeGreaterThan(0);
|
|
409
|
+
for (const entry of packages) {
|
|
410
|
+
expect(entry.package.startsWith('@astryxdesign/')).toBe(true);
|
|
411
|
+
expect(versionsOf(entry)).toEqual({
|
|
412
|
+
latest: '0.7.1',
|
|
413
|
+
versions: [['0.7.1', false]],
|
|
414
|
+
});
|
|
415
|
+
expect(entry.contributions.length).toBeGreaterThan(0);
|
|
416
|
+
}
|
|
417
|
+
expect(packages.map(p => p.package)).toContain(NEUTRAL);
|
|
418
|
+
for (const name of canaryOnlyNames()) {
|
|
419
|
+
expect(find(packages, name)).toBeUndefined();
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
it('lists the latest release and the project’s Core version, and pins the Core version', () => {
|
|
424
|
+
for (const [core, latest, versions] of [
|
|
425
|
+
[
|
|
426
|
+
'0.6.8',
|
|
427
|
+
'0.7.1',
|
|
428
|
+
[
|
|
429
|
+
['0.7.1', false],
|
|
430
|
+
['0.6.8', false],
|
|
431
|
+
],
|
|
432
|
+
],
|
|
433
|
+
[
|
|
434
|
+
'0.8.0',
|
|
435
|
+
'0.8.0',
|
|
436
|
+
[
|
|
437
|
+
['0.8.0', false],
|
|
438
|
+
['0.7.1', false],
|
|
439
|
+
],
|
|
440
|
+
],
|
|
441
|
+
['0.7.1', '0.7.1', [['0.7.1', false]]],
|
|
442
|
+
[
|
|
443
|
+
'0.7.1-canary.def5678',
|
|
444
|
+
'0.7.1',
|
|
445
|
+
[
|
|
446
|
+
['0.7.1', false],
|
|
447
|
+
['0.7.1-canary.def5678', true],
|
|
448
|
+
],
|
|
449
|
+
],
|
|
450
|
+
[
|
|
451
|
+
'0.7.2-canary.def5678',
|
|
452
|
+
'0.7.1',
|
|
453
|
+
[
|
|
454
|
+
['0.7.2-canary.def5678', true],
|
|
455
|
+
['0.7.1', false],
|
|
456
|
+
],
|
|
457
|
+
],
|
|
458
|
+
]) {
|
|
459
|
+
const dir = fs.mkdtempSync(path.join(cacheDir, 'core-'));
|
|
460
|
+
const entry = find(
|
|
461
|
+
officialList({version: '0.7.1', project: withCore(dir, core)}).packages,
|
|
462
|
+
NEUTRAL,
|
|
463
|
+
);
|
|
464
|
+
expect(versionsOf(entry), core).toEqual({latest, versions});
|
|
465
|
+
expect(entry.pin, core).toBe(core);
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
it('pins the Core version or range a fresh clone declares, and nothing for another spec', () => {
|
|
470
|
+
const p = project({cwd: path.join(cacheDir, 'src')});
|
|
471
|
+
for (const [spec, pin, versions] of [
|
|
472
|
+
[
|
|
473
|
+
'0.6.8',
|
|
474
|
+
'0.6.8',
|
|
475
|
+
[
|
|
476
|
+
['0.7.1', false],
|
|
477
|
+
['0.6.8', false],
|
|
478
|
+
],
|
|
479
|
+
],
|
|
480
|
+
[
|
|
481
|
+
'=0.6.8',
|
|
482
|
+
'0.6.8',
|
|
483
|
+
[
|
|
484
|
+
['0.7.1', false],
|
|
485
|
+
['0.6.8', false],
|
|
486
|
+
],
|
|
487
|
+
],
|
|
488
|
+
['^0.6.8', '^0.6.8', [['0.7.1', false]]],
|
|
489
|
+
['>=0.6.8 <0.8.0', '>=0.6.8 <0.8.0', [['0.7.1', false]]],
|
|
490
|
+
['0.6.x || ^0.7.0', '0.6.x || ^0.7.0', [['0.7.1', false]]],
|
|
491
|
+
// A space after an operator: node-semver reads both as >=0.6.8 <0.7.0.
|
|
492
|
+
['~ 0.6.8', '~0.6.8', [['0.7.1', false]]],
|
|
493
|
+
['>= 0.6.8 < 0.7.0', '>=0.6.8 <0.7.0', [['0.7.1', false]]],
|
|
494
|
+
['workspace:*', '0.7.1', [['0.7.1', false]]],
|
|
495
|
+
['file:../core', '0.7.1', [['0.7.1', false]]],
|
|
496
|
+
['latest', '0.7.1', [['0.7.1', false]]],
|
|
497
|
+
]) {
|
|
498
|
+
fs.writeFileSync(
|
|
499
|
+
path.join(cacheDir, 'package.json'),
|
|
500
|
+
JSON.stringify({devDependencies: {'@astryxdesign/core': spec}}),
|
|
501
|
+
);
|
|
502
|
+
const entry = find(
|
|
503
|
+
officialList({version: '0.7.1', project: p}).packages,
|
|
504
|
+
NEUTRAL,
|
|
505
|
+
);
|
|
506
|
+
expect(versionsOf(entry), spec).toEqual({latest: '0.7.1', versions});
|
|
507
|
+
expect(entry.pin, spec).toBe(pin);
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
it('on a canary CLI with no Core, pins only the canary-only packages', () => {
|
|
512
|
+
const canary = officialList({
|
|
513
|
+
version: '0.7.2-canary.abc1234',
|
|
514
|
+
project: project({cwd: cacheDir}),
|
|
515
|
+
}).packages;
|
|
516
|
+
expect(versionsOf(find(canary, NEUTRAL))).toEqual({
|
|
517
|
+
latest: null,
|
|
518
|
+
versions: [],
|
|
519
|
+
});
|
|
520
|
+
expect(find(canary, NEUTRAL).pin).toBeUndefined();
|
|
521
|
+
const names = canaryOnlyNames();
|
|
522
|
+
expect(names.length).toBeGreaterThan(0);
|
|
523
|
+
for (const name of names) {
|
|
524
|
+
expect(versionsOf(find(canary, name)), name).toEqual({
|
|
525
|
+
latest: null,
|
|
526
|
+
versions: [['0.7.2-canary.abc1234', true]],
|
|
527
|
+
});
|
|
528
|
+
expect(find(canary, name).pin, name).toBe('0.7.2-canary.abc1234');
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
it('lists the canary-only packages beside a canary Core, never beside a released one', () => {
|
|
533
|
+
const released = officialList({
|
|
534
|
+
version: '0.7.2-canary.abc1234',
|
|
535
|
+
project: withCore(cacheDir, '0.7.1'),
|
|
536
|
+
}).packages;
|
|
537
|
+
expect(versionsOf(find(released, NEUTRAL))).toEqual({
|
|
538
|
+
latest: '0.7.1',
|
|
539
|
+
versions: [['0.7.1', false]],
|
|
540
|
+
});
|
|
541
|
+
for (const name of canaryOnlyNames()) {
|
|
542
|
+
expect(find(released, name), name).toBeUndefined();
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
fs.writeFileSync(
|
|
546
|
+
path.join(cacheDir, 'package.json'),
|
|
547
|
+
JSON.stringify({dependencies: {'@astryxdesign/core': '^0.7.0'}}),
|
|
548
|
+
);
|
|
549
|
+
const declared = officialList({
|
|
550
|
+
version: '0.7.2-canary.abc1234',
|
|
551
|
+
project: project({cwd: cacheDir}),
|
|
552
|
+
}).packages;
|
|
553
|
+
for (const name of canaryOnlyNames()) {
|
|
554
|
+
expect(find(declared, name), name).toBeUndefined();
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
const beside = officialList({
|
|
558
|
+
version: '0.7.2-canary.abc1234',
|
|
559
|
+
project: withCore(cacheDir, '0.7.2-canary.def5678'),
|
|
560
|
+
}).packages;
|
|
561
|
+
for (const name of canaryOnlyNames()) {
|
|
562
|
+
expect(versionsOf(find(beside, name)), name).toEqual({
|
|
563
|
+
latest: null,
|
|
564
|
+
versions: [['0.7.2-canary.def5678', true]],
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
it('reads back as a valid discover catalog on a release and a canary CLI', () => {
|
|
570
|
+
for (const version of ['0.7.1', '0.7.2-canary.abc1234']) {
|
|
571
|
+
const packages = officialList({version}).packages.map(
|
|
572
|
+
({pin: _pin, ...entry}) => entry,
|
|
573
|
+
);
|
|
574
|
+
const parsed = parseDiscoverCatalog(
|
|
575
|
+
catalog('Astryx', packages),
|
|
576
|
+
'the official list',
|
|
577
|
+
);
|
|
578
|
+
expect(parsed.packages).toEqual(packages);
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
it('reports a list it cannot read instead of throwing', () => {
|
|
583
|
+
const result = officialList({
|
|
584
|
+
file: path.join(cacheDir, 'missing.json'),
|
|
585
|
+
version: '0.7.1',
|
|
586
|
+
});
|
|
587
|
+
expect(result.packages).toEqual([]);
|
|
588
|
+
expect(result.error).toContain('the official list could not be read');
|
|
589
|
+
});
|
|
590
|
+
|
|
591
|
+
it('pins what each entry names, quoting a range, and the pin is a version it lists', () => {
|
|
592
|
+
for (const [cli, core, declared] of [
|
|
593
|
+
['0.7.1', '0.6.8', undefined],
|
|
594
|
+
['0.7.1', '0.8.0', undefined],
|
|
595
|
+
['0.7.1', undefined, '^0.6.8'],
|
|
596
|
+
['0.7.1', undefined, '>=0.6.8 <0.8.0'],
|
|
597
|
+
['0.7.2-canary.abc1234', undefined, undefined],
|
|
598
|
+
['0.7.2-canary.abc1234', '0.7.2-canary.def5678', undefined],
|
|
599
|
+
]) {
|
|
600
|
+
const dir = fs.mkdtempSync(path.join(cacheDir, 'pin-'));
|
|
601
|
+
if (declared) {
|
|
602
|
+
fs.writeFileSync(
|
|
603
|
+
path.join(dir, 'package.json'),
|
|
604
|
+
JSON.stringify({dependencies: {'@astryxdesign/core': declared}}),
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
const p = core ? withCore(dir, core) : project({cwd: dir});
|
|
608
|
+
const {packages} = officialList({version: cli, project: p});
|
|
609
|
+
const add = addCommand(p, {official: packages});
|
|
610
|
+
for (const entry of packages) {
|
|
611
|
+
const label = `${cli} ${core ?? declared} ${entry.package}`;
|
|
612
|
+
const command = add(entry.package);
|
|
613
|
+
if (entry.pin == null) {
|
|
614
|
+
expect(command.endsWith(` ${entry.package}`), label).toBe(true);
|
|
615
|
+
} else if (entry.versions.some(v => v.version === entry.pin)) {
|
|
616
|
+
expect(
|
|
617
|
+
command.endsWith(` ${entry.package}@${entry.pin}`),
|
|
618
|
+
label,
|
|
619
|
+
).toBe(true);
|
|
620
|
+
} else {
|
|
621
|
+
// Only a declared range is pinned without being a listed version.
|
|
622
|
+
expect(entry.pin, label).toBe(declared);
|
|
623
|
+
expect(
|
|
624
|
+
command.endsWith(` "${entry.package}@${declared}"`),
|
|
625
|
+
label,
|
|
626
|
+
).toBe(true);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
});
|
|
632
|
+
|
|
633
|
+
describe('officialDeclarations', () => {
|
|
634
|
+
const list = [
|
|
635
|
+
official('@astryxdesign/theme-gothic'),
|
|
636
|
+
official('@astryxdesign/theme-matcha'),
|
|
637
|
+
official('@astryxdesign/theme-stone'),
|
|
638
|
+
];
|
|
639
|
+
|
|
640
|
+
it('reads the project’s own package.json from a subfolder, aliases included, and keeps peers apart', () => {
|
|
641
|
+
fs.writeFileSync(
|
|
642
|
+
path.join(cacheDir, 'package.json'),
|
|
643
|
+
JSON.stringify({
|
|
644
|
+
dependencies: {
|
|
645
|
+
'my-gothic': 'npm:@astryxdesign/theme-gothic@0.7.0',
|
|
646
|
+
react: '19.0.0',
|
|
647
|
+
},
|
|
648
|
+
devDependencies: {'@astryxdesign/theme-matcha': '0.7.0'},
|
|
649
|
+
peerDependencies: {'@astryxdesign/theme-stone': '>=0.7.0'},
|
|
650
|
+
}),
|
|
651
|
+
);
|
|
652
|
+
const declared = officialDeclarations(
|
|
653
|
+
project({cwd: path.join(cacheDir, 'src', 'components')}),
|
|
654
|
+
list,
|
|
655
|
+
);
|
|
656
|
+
expect([...declared.dependency]).toEqual([
|
|
657
|
+
['@astryxdesign/theme-gothic', 'my-gothic'],
|
|
658
|
+
['@astryxdesign/theme-matcha', '@astryxdesign/theme-matcha'],
|
|
659
|
+
]);
|
|
660
|
+
expect([...declared.any].sort()).toEqual([
|
|
661
|
+
'@astryxdesign/theme-gothic',
|
|
662
|
+
'@astryxdesign/theme-matcha',
|
|
663
|
+
'@astryxdesign/theme-stone',
|
|
664
|
+
]);
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
|
|
668
|
+
describe('withDeclaredOfficial', () => {
|
|
669
|
+
/** @param {string} dir @param {string} name @param {string} version */
|
|
670
|
+
function install(dir, name, version) {
|
|
671
|
+
const at = path.join(dir, 'node_modules', ...name.split('/'));
|
|
672
|
+
fs.mkdirSync(at, {recursive: true});
|
|
673
|
+
fs.writeFileSync(
|
|
674
|
+
path.join(at, 'package.json'),
|
|
675
|
+
JSON.stringify({name, version}),
|
|
676
|
+
);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
/** @param {object[]} packages */
|
|
680
|
+
const result = packages => ({sources: [], packages});
|
|
681
|
+
/** @param {Array<[string, string]>} entries */
|
|
682
|
+
const declares = entries => ({
|
|
683
|
+
dependency: new Map(entries),
|
|
684
|
+
any: new Set(entries.map(([name]) => name)),
|
|
685
|
+
});
|
|
686
|
+
const gothic = {
|
|
687
|
+
...official('@astryxdesign/theme-gothic', {description: 'Dark.'}),
|
|
688
|
+
source: 'Astryx',
|
|
689
|
+
official: true,
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
it('counts a declared official package as installed, first, with its installed version', () => {
|
|
693
|
+
install(cacheDir, '@astryxdesign/theme-gothic', '0.7.0');
|
|
694
|
+
const installed = withDeclaredOfficial(
|
|
695
|
+
project({cwd: cacheDir}),
|
|
696
|
+
[{name: '@acme/ui', category: '@acme/ui', components: []}],
|
|
697
|
+
result([gothic]),
|
|
698
|
+
declares([['@astryxdesign/theme-gothic', '@astryxdesign/theme-gothic']]),
|
|
699
|
+
[gothic],
|
|
700
|
+
);
|
|
701
|
+
expect(installed).toEqual([
|
|
702
|
+
{
|
|
703
|
+
name: '@astryxdesign/theme-gothic',
|
|
704
|
+
category: '@astryxdesign/theme-gothic',
|
|
705
|
+
version: '0.7.0',
|
|
706
|
+
description: 'Dark.',
|
|
707
|
+
components: [],
|
|
708
|
+
themes: ['gothic'],
|
|
709
|
+
declaredOfficial: true,
|
|
710
|
+
},
|
|
711
|
+
{name: '@acme/ui', category: '@acme/ui', components: []},
|
|
712
|
+
]);
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
it('reads the version of a package installed under an npm alias', () => {
|
|
716
|
+
install(cacheDir, 'my-gothic', '0.6.8');
|
|
717
|
+
const [entry] = withDeclaredOfficial(
|
|
718
|
+
project({cwd: cacheDir}),
|
|
719
|
+
[],
|
|
720
|
+
result([gothic]),
|
|
721
|
+
declares([['@astryxdesign/theme-gothic', 'my-gothic']]),
|
|
722
|
+
[gothic],
|
|
723
|
+
);
|
|
724
|
+
expect(entry).toMatchObject({
|
|
725
|
+
name: '@astryxdesign/theme-gothic',
|
|
726
|
+
version: '0.6.8',
|
|
727
|
+
});
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
it('leaves a declared official package alone when another source supplied its entry', () => {
|
|
731
|
+
const fromOwn = {...gothic, source: 'Own', official: undefined};
|
|
732
|
+
expect(
|
|
733
|
+
withDeclaredOfficial(
|
|
734
|
+
project({cwd: cacheDir}),
|
|
735
|
+
[],
|
|
736
|
+
result([fromOwn]),
|
|
737
|
+
declares([
|
|
738
|
+
['@astryxdesign/theme-gothic', '@astryxdesign/theme-gothic'],
|
|
739
|
+
]),
|
|
740
|
+
[gothic],
|
|
741
|
+
),
|
|
742
|
+
).toEqual([]);
|
|
743
|
+
});
|
|
744
|
+
|
|
745
|
+
it('leaves out an official integration that failed to load, even when declared', () => {
|
|
746
|
+
expect(
|
|
747
|
+
withDeclaredOfficial(
|
|
748
|
+
project({
|
|
749
|
+
cwd: cacheDir,
|
|
750
|
+
integrations: [
|
|
751
|
+
{name: '@astryxdesign/theme-gothic', __loadError: 'x'},
|
|
752
|
+
],
|
|
753
|
+
}),
|
|
754
|
+
[],
|
|
755
|
+
result([gothic]),
|
|
756
|
+
declares([
|
|
757
|
+
['@astryxdesign/theme-gothic', '@astryxdesign/theme-gothic'],
|
|
758
|
+
]),
|
|
759
|
+
[gothic],
|
|
760
|
+
),
|
|
761
|
+
).toEqual([]);
|
|
762
|
+
});
|
|
763
|
+
});
|
|
764
|
+
|
|
765
|
+
describe('addCommand with the official list', () => {
|
|
766
|
+
const list = [
|
|
767
|
+
official('@astryxdesign/theme-gothic', {pin: '0.6.8'}),
|
|
768
|
+
official('@astryxdesign/theme-matcha', {pin: '^0.6.8'}),
|
|
769
|
+
official('@astryxdesign/theme-stone', {pin: undefined}),
|
|
770
|
+
official('@astryxdesign/charts', {pin: '0.7.2-canary.abc1234'}),
|
|
771
|
+
];
|
|
772
|
+
const add = () => addCommand(project({cwd: cacheDir}), {official: list});
|
|
773
|
+
|
|
774
|
+
it('pins what an official entry names, quoting a range', () => {
|
|
775
|
+
const command = add();
|
|
776
|
+
expect(command('@astryxdesign/theme-gothic')).toMatch(
|
|
777
|
+
/ @astryxdesign\/theme-gothic@0\.6\.8$/,
|
|
778
|
+
);
|
|
779
|
+
expect(command('@astryxdesign/theme-matcha')).toMatch(
|
|
780
|
+
/ "@astryxdesign\/theme-matcha@\^0\.6\.8"$/,
|
|
781
|
+
);
|
|
782
|
+
expect(command('@astryxdesign/theme-stone')).toMatch(
|
|
783
|
+
/ @astryxdesign\/theme-stone$/,
|
|
784
|
+
);
|
|
785
|
+
expect(command('@astryxdesign/charts')).toMatch(
|
|
786
|
+
/ @astryxdesign\/charts@0\.7\.2-canary\.abc1234$/,
|
|
787
|
+
);
|
|
788
|
+
});
|
|
789
|
+
|
|
790
|
+
it('adds a version that was asked for, and leaves other packages alone', () => {
|
|
791
|
+
const command = add();
|
|
792
|
+
expect(command('@acme/ui')).toMatch(/ @acme\/ui$/);
|
|
793
|
+
expect(command('@astryxdesign/theme-matcha', '0.7.1')).toMatch(
|
|
794
|
+
/ @astryxdesign\/theme-matcha@0\.7\.1$/,
|
|
795
|
+
);
|
|
214
796
|
});
|
|
215
797
|
});
|