@nx/storybook 18.1.0-beta.2 → 18.1.0-beta.3
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/storybook",
|
|
3
|
-
"version": "18.1.0-beta.
|
|
3
|
+
"version": "18.1.0-beta.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Storybook contains executors and generators for allowing your workspace to use the powerful Storybook integration testing & documenting capabilities.",
|
|
6
6
|
"repository": {
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"migrations": "./migrations.json"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@nx/devkit": "18.1.0-beta.
|
|
33
|
+
"@nx/devkit": "18.1.0-beta.3",
|
|
34
34
|
"@phenomnomnominal/tsquery": "~5.0.1",
|
|
35
35
|
"semver": "^7.5.3",
|
|
36
36
|
"tslib": "^2.3.0",
|
|
37
|
-
"@nx/cypress": "18.1.0-beta.
|
|
38
|
-
"@nx/js": "18.1.0-beta.
|
|
39
|
-
"@nx/eslint": "18.1.0-beta.
|
|
40
|
-
"@nrwl/storybook": "18.1.0-beta.
|
|
37
|
+
"@nx/cypress": "18.1.0-beta.3",
|
|
38
|
+
"@nx/js": "18.1.0-beta.3",
|
|
39
|
+
"@nx/eslint": "18.1.0-beta.3",
|
|
40
|
+
"@nrwl/storybook": "18.1.0-beta.3"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
@@ -20,7 +20,7 @@ async function configurationGeneratorInternal(tree, rawSchema) {
|
|
|
20
20
|
if ((0, utilities_1.storybookMajorVersion)() === 6) {
|
|
21
21
|
throw new Error((0, utilities_1.pleaseUpgrade)());
|
|
22
22
|
}
|
|
23
|
-
const schema = normalizeSchema(rawSchema);
|
|
23
|
+
const schema = normalizeSchema(tree, rawSchema);
|
|
24
24
|
const tasks = [];
|
|
25
25
|
const { projectType, targets, root } = (0, devkit_1.readProjectConfiguration)(tree, schema.project);
|
|
26
26
|
const { compiler } = (0, utilities_1.findStorybookAndBuildTargetsAndCompiler)(targets);
|
|
@@ -147,13 +147,16 @@ async function configurationGeneratorInternal(tree, rawSchema) {
|
|
|
147
147
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
148
148
|
}
|
|
149
149
|
exports.configurationGeneratorInternal = configurationGeneratorInternal;
|
|
150
|
-
function normalizeSchema(schema) {
|
|
150
|
+
function normalizeSchema(tree, schema) {
|
|
151
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
152
|
+
const addPlugin = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
153
|
+
nxJson.useInferencePlugins !== false;
|
|
151
154
|
const defaults = {
|
|
152
155
|
interactionTests: true,
|
|
153
156
|
linter: eslint_1.Linter.EsLint,
|
|
154
157
|
js: false,
|
|
155
158
|
tsConfiguration: true,
|
|
156
|
-
addPlugin
|
|
159
|
+
addPlugin,
|
|
157
160
|
};
|
|
158
161
|
return {
|
|
159
162
|
...defaults,
|
|
@@ -299,6 +299,10 @@ function updateLintConfig(tree, schema) {
|
|
|
299
299
|
]);
|
|
300
300
|
}
|
|
301
301
|
}
|
|
302
|
+
const ignorePatterns = json.ignorePatterns || [];
|
|
303
|
+
if (!ignorePatterns.includes('storybook-static')) {
|
|
304
|
+
ignorePatterns.push('storybook-static');
|
|
305
|
+
}
|
|
302
306
|
return json;
|
|
303
307
|
});
|
|
304
308
|
}
|
|
@@ -55,7 +55,10 @@ function initGenerator(tree, schema) {
|
|
|
55
55
|
}
|
|
56
56
|
exports.initGenerator = initGenerator;
|
|
57
57
|
async function initGeneratorInternal(tree, schema) {
|
|
58
|
-
|
|
58
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
59
|
+
const addPluginDefault = process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
60
|
+
nxJson.useInferencePlugins !== false;
|
|
61
|
+
schema.addPlugin ??= addPluginDefault;
|
|
59
62
|
if (schema.addPlugin) {
|
|
60
63
|
(0, utilities_1.addPlugin)(tree);
|
|
61
64
|
(0, update_gitignore_1.updateGitignore)(tree);
|
package/src/plugins/plugin.js
CHANGED
|
@@ -65,7 +65,7 @@ exports.createNodes = [
|
|
|
65
65
|
function buildStorybookTargets(configFilePath, projectRoot, options, context, projectName) {
|
|
66
66
|
const buildOutputs = getOutputs(projectRoot);
|
|
67
67
|
const namedInputs = (0, get_named_inputs_1.getNamedInputs)(projectRoot, context);
|
|
68
|
-
const storybookFramework =
|
|
68
|
+
const storybookFramework = getStorybookFramework(configFilePath, context);
|
|
69
69
|
const frameworkIsAngular = storybookFramework === "'@storybook/angular'";
|
|
70
70
|
if (frameworkIsAngular && !projectName) {
|
|
71
71
|
throw new Error(`Could not find a name for the project at '${projectRoot}'. Please make sure that the project has a package.json or project.json file with name specified.`);
|
|
@@ -162,35 +162,33 @@ function serveStaticTarget(options, projectRoot) {
|
|
|
162
162
|
};
|
|
163
163
|
return targetConfig;
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function getStorybookFramework(configFilePath, context) {
|
|
166
166
|
const resolvedPath = (0, path_1.join)(context.workspaceRoot, configFilePath);
|
|
167
167
|
const mainTsJs = (0, fs_1.readFileSync)(resolvedPath, 'utf-8');
|
|
168
168
|
const importDeclarations = tsquery_1.tsquery.query(mainTsJs, 'ImportDeclaration:has(ImportSpecifier:has([text="StorybookConfig"]))')?.[0];
|
|
169
|
+
if (!importDeclarations) {
|
|
170
|
+
return parseFrameworkName(mainTsJs);
|
|
171
|
+
}
|
|
169
172
|
const storybookConfigImportPackage = tsquery_1.tsquery.query(importDeclarations, 'StringLiteral')?.[0];
|
|
170
|
-
let frameworkName;
|
|
171
173
|
if (storybookConfigImportPackage?.getText() === `'@storybook/core-common'`) {
|
|
172
|
-
|
|
173
|
-
if (!frameworkPropertyAssignment) {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
const propertyAssignments = tsquery_1.tsquery.query(frameworkPropertyAssignment, `PropertyAssignment:has(Identifier:has([text="name"]))`);
|
|
177
|
-
const namePropertyAssignment = propertyAssignments?.find((expression) => {
|
|
178
|
-
return expression.getText().startsWith('name');
|
|
179
|
-
});
|
|
180
|
-
if (!namePropertyAssignment) {
|
|
181
|
-
const storybookConfigImportPackage = tsquery_1.tsquery.query(frameworkPropertyAssignment, 'StringLiteral')?.[0];
|
|
182
|
-
frameworkName = storybookConfigImportPackage?.getText();
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
frameworkName = tsquery_1.tsquery
|
|
186
|
-
.query(namePropertyAssignment, `StringLiteral`)?.[0]
|
|
187
|
-
?.getText();
|
|
188
|
-
}
|
|
174
|
+
return parseFrameworkName(mainTsJs);
|
|
189
175
|
}
|
|
190
|
-
|
|
191
|
-
|
|
176
|
+
return storybookConfigImportPackage?.getText();
|
|
177
|
+
}
|
|
178
|
+
function parseFrameworkName(mainTsJs) {
|
|
179
|
+
const frameworkPropertyAssignment = tsquery_1.tsquery.query(mainTsJs, `PropertyAssignment:has(Identifier:has([text="framework"]))`)?.[0];
|
|
180
|
+
if (!frameworkPropertyAssignment) {
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
const propertyAssignments = tsquery_1.tsquery.query(frameworkPropertyAssignment, `PropertyAssignment:has(Identifier:has([text="name"]))`);
|
|
184
|
+
const namePropertyAssignment = propertyAssignments?.find((expression) => {
|
|
185
|
+
return expression.getText().startsWith('name');
|
|
186
|
+
});
|
|
187
|
+
if (!namePropertyAssignment) {
|
|
188
|
+
const storybookConfigImportPackage = tsquery_1.tsquery.query(frameworkPropertyAssignment, 'StringLiteral')?.[0];
|
|
189
|
+
return storybookConfigImportPackage?.getText();
|
|
192
190
|
}
|
|
193
|
-
return
|
|
191
|
+
return tsquery_1.tsquery.query(namePropertyAssignment, `StringLiteral`)?.[0]?.getText();
|
|
194
192
|
}
|
|
195
193
|
function getOutputs(projectRoot) {
|
|
196
194
|
const normalizedOutputPath = normalizeOutputPath(projectRoot);
|