@nx/react-native 16.1.0-beta.0 → 16.1.0-rc.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/migrations.json +19 -0
- package/package.json +11 -10
- package/src/executors/build-ios/schema.json +2 -1
- package/src/executors/run-ios/schema.json +1 -1
- package/src/executors/storybook/schema.d.ts +3 -1
- package/src/executors/storybook/schema.json +3 -2
- package/src/executors/storybook/storybook.impl.d.ts +2 -1
- package/src/executors/storybook/storybook.impl.js +24 -52
- package/src/executors/storybook/storybook.impl.js.map +1 -1
- package/src/executors/storybook/storybook.impl.ts +23 -56
- package/src/generators/component-story/component-story.d.ts +7 -3
- package/src/generators/component-story/component-story.js +10 -42
- package/src/generators/component-story/component-story.js.map +1 -1
- package/src/generators/component-story/component-story.spec.ts +45 -50
- package/src/generators/component-story/files/__componentFileName__.stories.__fileExt__ +28 -20
- package/src/generators/storybook-configuration/configuration.js +7 -4
- package/src/generators/storybook-configuration/configuration.js.map +1 -1
- package/src/generators/storybook-configuration/configuration.spec.ts +0 -9
- package/src/generators/storybook-configuration/files/app/storybook.ts.template +1 -1
- package/src/generators/storybook-configuration/files/root/story-loader.ts.template +5 -0
- package/src/migrations/update-16-1-0/upgrade-storybook-6-5.d.ts +7 -0
- package/src/migrations/update-16-1-0/upgrade-storybook-6-5.js +20 -0
- package/src/migrations/update-16-1-0/upgrade-storybook-6-5.js.map +1 -0
- package/src/utils/pod-install-task.js +0 -7
- package/src/utils/pod-install-task.js.map +1 -1
- package/src/utils/versions.d.ts +2 -0
- package/src/utils/versions.js +3 -1
- package/src/utils/versions.js.map +1 -1
- package/src/generators/storybook-configuration/files/root/story-loader.js.template +0 -13
package/migrations.json
CHANGED
|
@@ -83,6 +83,12 @@
|
|
|
83
83
|
"version": "16.0.0-beta.1",
|
|
84
84
|
"description": "Replace @nrwl/react-native with @nx/react-native",
|
|
85
85
|
"implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
|
|
86
|
+
},
|
|
87
|
+
"update-16-1-0-upgrade-storybook-6-5": {
|
|
88
|
+
"cli": "nx",
|
|
89
|
+
"version": "16.1.0-beta.0",
|
|
90
|
+
"description": "Upgrade @storybook/react-native to 6.5",
|
|
91
|
+
"implementation": "./src/migrations/update-16-1-0/upgrade-storybook-6-5"
|
|
86
92
|
}
|
|
87
93
|
},
|
|
88
94
|
"packageJsonUpdates": {
|
|
@@ -1291,6 +1297,19 @@
|
|
|
1291
1297
|
"alwaysAddToPackageJson": false
|
|
1292
1298
|
}
|
|
1293
1299
|
}
|
|
1300
|
+
},
|
|
1301
|
+
"16.0.2": {
|
|
1302
|
+
"version": "16.0.2-beta.0",
|
|
1303
|
+
"packages": {
|
|
1304
|
+
"@react-native-async-storage/async-storage": {
|
|
1305
|
+
"version": "1.18.1",
|
|
1306
|
+
"alwaysAddToPackageJson": false
|
|
1307
|
+
},
|
|
1308
|
+
"react-native-safe-area-context": {
|
|
1309
|
+
"version": "4.5.1",
|
|
1310
|
+
"alwaysAddToPackageJson": false
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1294
1313
|
}
|
|
1295
1314
|
}
|
|
1296
1315
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/react-native",
|
|
3
|
-
"version": "16.1.0-
|
|
3
|
+
"version": "16.1.0-rc.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for React Native contains generators for managing React Native applications and libraries within an Nx workspace. It provides: \n\n-Integration with libraries such as Jest, Detox, and Storybook.\n-Scaffolding for creating buildable libraries that can be published to npm.\n-Utilities for automatic workspace refactoring.",
|
|
6
6
|
"keywords": [
|
|
@@ -25,17 +25,18 @@
|
|
|
25
25
|
"main": "./index",
|
|
26
26
|
"types": "index.d.ts",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@nrwl/react-native": "16.1.0-
|
|
29
|
-
"@nx/detox": "16.1.0-
|
|
30
|
-
"@nx/devkit": "16.1.0-
|
|
31
|
-
"@nx/jest": "16.1.0-
|
|
32
|
-
"@nx/js": "16.1.0-
|
|
33
|
-
"@nx/linter": "16.1.0-
|
|
34
|
-
"@nx/react": "16.1.0-
|
|
35
|
-
"@nx/workspace": "16.1.0-
|
|
28
|
+
"@nrwl/react-native": "16.1.0-rc.0",
|
|
29
|
+
"@nx/detox": "16.1.0-rc.0",
|
|
30
|
+
"@nx/devkit": "16.1.0-rc.0",
|
|
31
|
+
"@nx/jest": "16.1.0-rc.0",
|
|
32
|
+
"@nx/js": "16.1.0-rc.0",
|
|
33
|
+
"@nx/linter": "16.1.0-rc.0",
|
|
34
|
+
"@nx/react": "16.1.0-rc.0",
|
|
35
|
+
"@nx/workspace": "16.1.0-rc.0",
|
|
36
36
|
"chalk": "^4.1.0",
|
|
37
37
|
"enhanced-resolve": "^5.8.3",
|
|
38
38
|
"fs-extra": "^11.1.0",
|
|
39
|
+
"glob": "7.1.4",
|
|
39
40
|
"ignore": "^5.0.4",
|
|
40
41
|
"metro-resolver": "^0.74.1",
|
|
41
42
|
"minimatch": "3.0.5",
|
|
@@ -54,5 +55,5 @@
|
|
|
54
55
|
"publishConfig": {
|
|
55
56
|
"access": "public"
|
|
56
57
|
},
|
|
57
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "8cc64baf9537e775fcc5f2e606687ea3d01308ab"
|
|
58
59
|
}
|
|
@@ -83,7 +83,8 @@
|
|
|
83
83
|
},
|
|
84
84
|
"install": {
|
|
85
85
|
"type": "boolean",
|
|
86
|
-
"description": "Runs `pod install` for native modules before building iOS app."
|
|
86
|
+
"description": "Runs `pod install` for native modules before building iOS app.",
|
|
87
|
+
"default": true
|
|
87
88
|
},
|
|
88
89
|
"sync": {
|
|
89
90
|
"type": "boolean",
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
// options from https://github.com/elderfo/react-native-storybook-loader#options
|
|
2
1
|
export interface ReactNativeStorybookOptions {
|
|
3
2
|
searchDir: string[];
|
|
4
3
|
outputFile: string;
|
|
5
4
|
pattern: string;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated going to be removed in 17
|
|
7
|
+
*/
|
|
6
8
|
silent: boolean;
|
|
7
9
|
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"outputFile": {
|
|
18
18
|
"type": "string",
|
|
19
19
|
"description": "The output file that will be written. It is relative to the project directory.",
|
|
20
|
-
"default": "./.storybook/story-loader.
|
|
20
|
+
"default": "./.storybook/story-loader.ts"
|
|
21
21
|
},
|
|
22
22
|
"pattern": {
|
|
23
23
|
"type": "string",
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"silent": {
|
|
28
28
|
"type": "boolean",
|
|
29
29
|
"description": "Silences output.",
|
|
30
|
-
"default": false
|
|
30
|
+
"default": false,
|
|
31
|
+
"x-deprecated": "No longer used. It will be silent as default."
|
|
31
32
|
}
|
|
32
33
|
},
|
|
33
34
|
"required": ["searchDir", "outputFile", "pattern"]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ExecutorContext } from '@nx/devkit';
|
|
2
2
|
import { ReactNativeStorybookOptions } from './schema';
|
|
3
|
-
export default function
|
|
3
|
+
export default function reactNativeStorybookExecutor(options: ReactNativeStorybookOptions, context: ExecutorContext): AsyncGenerator<{
|
|
4
4
|
success: boolean;
|
|
5
5
|
}>;
|
|
6
|
+
export declare function runCliStorybook(workspaceRoot: string, options: ReactNativeStorybookOptions): void;
|
|
@@ -1,76 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runCliStorybook = void 0;
|
|
3
4
|
const tslib_1 = require("tslib");
|
|
4
5
|
const path_1 = require("path");
|
|
5
6
|
const devkit_1 = require("@nx/devkit");
|
|
6
7
|
const fileutils_1 = require("@nx/workspace/src/utilities/fileutils");
|
|
7
8
|
const chalk = require("chalk");
|
|
8
|
-
const
|
|
9
|
+
const glob_1 = require("glob");
|
|
9
10
|
const sync_deps_impl_1 = require("../sync-deps/sync-deps.impl");
|
|
10
|
-
|
|
11
|
-
function
|
|
12
|
-
return tslib_1.__asyncGenerator(this, arguments, function*
|
|
11
|
+
const fs_extra_1 = require("fs-extra");
|
|
12
|
+
function reactNativeStorybookExecutor(options, context) {
|
|
13
|
+
return tslib_1.__asyncGenerator(this, arguments, function* reactNativeStorybookExecutor_1() {
|
|
13
14
|
const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
|
|
14
15
|
devkit_1.logger.info(`${chalk.bold.cyan('info')} To see your Storybook stories on the device, you should start your mobile app for the <platform> of your choice (typically ios or android).`);
|
|
15
16
|
// add storybook addons to app's package.json
|
|
16
17
|
const packageJsonPath = (0, path_1.join)(context.root, projectRoot, 'package.json');
|
|
17
18
|
if ((0, fileutils_1.fileExists)(packageJsonPath))
|
|
18
19
|
(0, sync_deps_impl_1.displayNewlyAddedDepsMessage)(context.projectName, yield tslib_1.__await((0, sync_deps_impl_1.syncDeps)(context.projectName, projectRoot, context.root, context.projectGraph, [
|
|
20
|
+
`@storybook/react-native`,
|
|
19
21
|
'@storybook/addon-ondevice-actions',
|
|
20
22
|
'@storybook/addon-ondevice-backgrounds',
|
|
21
23
|
'@storybook/addon-ondevice-controls',
|
|
22
24
|
'@storybook/addon-ondevice-notes',
|
|
25
|
+
'@react-native-async-storage/async-storage',
|
|
26
|
+
'react-native-safe-area-context',
|
|
23
27
|
])));
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
yield yield tslib_1.__await({ success: true });
|
|
27
|
-
}
|
|
28
|
-
finally {
|
|
29
|
-
if (childProcess) {
|
|
30
|
-
childProcess.kill();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
28
|
+
runCliStorybook(context.root, options);
|
|
29
|
+
yield yield tslib_1.__await({ success: true });
|
|
33
30
|
});
|
|
34
31
|
}
|
|
35
|
-
exports.default =
|
|
32
|
+
exports.default = reactNativeStorybookExecutor;
|
|
36
33
|
function runCliStorybook(workspaceRoot, options) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
resolve(code);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
reject(code);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
function createStorybookOptions(options) {
|
|
58
|
-
return Object.keys(options).reduce((acc, k) => {
|
|
59
|
-
const v = options[k];
|
|
60
|
-
if (typeof v === 'boolean') {
|
|
61
|
-
if (v === true) {
|
|
62
|
-
acc.push(`--${k}`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
else if (Array.isArray(v)) {
|
|
66
|
-
v.forEach((value) => {
|
|
67
|
-
acc.push(`--${k}`, value);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
acc.push(`--${k}`, v);
|
|
72
|
-
}
|
|
73
|
-
return acc;
|
|
74
|
-
}, []);
|
|
34
|
+
const storiesFiles = options.searchDir.flatMap((dir) => (0, glob_1.sync)((0, path_1.join)(dir, options.pattern)));
|
|
35
|
+
if (storiesFiles.length === 0) {
|
|
36
|
+
devkit_1.logger.warn(`${chalk.bold.yellow('warn')} No stories found.`);
|
|
37
|
+
}
|
|
38
|
+
const newContents = `// Auto-generated file created by nx
|
|
39
|
+
// DO NOT EDIT.
|
|
40
|
+
export function loadStories() {
|
|
41
|
+
return [
|
|
42
|
+
${storiesFiles.map((story) => `require('${story}')`).join(',\n')}
|
|
43
|
+
];
|
|
44
|
+
}`;
|
|
45
|
+
(0, fs_extra_1.writeFileSync)((0, path_1.join)(workspaceRoot, options.outputFile), newContents);
|
|
75
46
|
}
|
|
47
|
+
exports.runCliStorybook = runCliStorybook;
|
|
76
48
|
//# sourceMappingURL=storybook.impl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storybook.impl.js","sourceRoot":"","sources":["../../../../../../packages/react-native/src/executors/storybook/storybook.impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storybook.impl.js","sourceRoot":"","sources":["../../../../../../packages/react-native/src/executors/storybook/storybook.impl.ts"],"names":[],"mappings":";;;;AAAA,+BAA4B;AAC5B,uCAAqD;AACrD,qEAAmE;AACnE,+BAA+B;AAC/B,+BAAwC;AAGxC,gEAGqC;AACrC,uCAAyC;AAEzC,SAA+B,4BAA4B,CACzD,OAAoC,EACpC,OAAwB;;QAExB,MAAM,WAAW,GACf,OAAO,CAAC,sBAAsB,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC;QACpE,eAAM,CAAC,IAAI,CACT,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAChB,MAAM,CACP,8IAA8I,CAChJ,CAAC;QAEF,6CAA6C;QAC7C,MAAM,eAAe,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;QACxE,IAAI,IAAA,sBAAU,EAAC,eAAe,CAAC;YAC7B,IAAA,6CAA4B,EAC1B,OAAO,CAAC,WAAW,EACnB,sBAAM,IAAA,yBAAQ,EACZ,OAAO,CAAC,WAAW,EACnB,WAAW,EACX,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,YAAY,EACpB;gBACE,yBAAyB;gBACzB,mCAAmC;gBACnC,uCAAuC;gBACvC,oCAAoC;gBACpC,iCAAiC;gBACjC,2CAA2C;gBAC3C,gCAAgC;aACjC,CACF,CAAA,CACF,CAAC;QAEJ,eAAe,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACvC,4BAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA,CAAC;IAC1B,CAAC;CAAA;AApCD,+CAoCC;AAED,SAAgB,eAAe,CAC7B,aAAqB,EACrB,OAAoC;IAEpC,MAAM,YAAY,GAAa,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,CAC/D,IAAA,WAAQ,EAAC,IAAA,WAAI,EAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CACrC,CAAC;IACF,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;QAC7B,eAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;KAC/D;IAED,MAAM,WAAW,GAAG;;;;MAIhB,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;;EAElE,CAAC;IAED,IAAA,wBAAa,EAAC,IAAA,WAAI,EAAC,aAAa,EAAE,OAAO,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,CAAC;AACtE,CAAC;AApBD,0CAoBC"}
|
|
@@ -2,17 +2,16 @@ import { join } from 'path';
|
|
|
2
2
|
import { ExecutorContext, logger } from '@nx/devkit';
|
|
3
3
|
import { fileExists } from '@nx/workspace/src/utilities/fileutils';
|
|
4
4
|
import * as chalk from 'chalk';
|
|
5
|
+
import { sync as globSync } from 'glob';
|
|
5
6
|
|
|
6
7
|
import { ReactNativeStorybookOptions } from './schema';
|
|
7
|
-
import { ChildProcess, fork } from 'child_process';
|
|
8
8
|
import {
|
|
9
9
|
displayNewlyAddedDepsMessage,
|
|
10
10
|
syncDeps,
|
|
11
11
|
} from '../sync-deps/sync-deps.impl';
|
|
12
|
+
import { writeFileSync } from 'fs-extra';
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export default async function* reactNatievStorybookExecutor(
|
|
14
|
+
export default async function* reactNativeStorybookExecutor(
|
|
16
15
|
options: ReactNativeStorybookOptions,
|
|
17
16
|
context: ExecutorContext
|
|
18
17
|
): AsyncGenerator<{ success: boolean }> {
|
|
@@ -35,71 +34,39 @@ export default async function* reactNatievStorybookExecutor(
|
|
|
35
34
|
context.root,
|
|
36
35
|
context.projectGraph,
|
|
37
36
|
[
|
|
37
|
+
`@storybook/react-native`,
|
|
38
38
|
'@storybook/addon-ondevice-actions',
|
|
39
39
|
'@storybook/addon-ondevice-backgrounds',
|
|
40
40
|
'@storybook/addon-ondevice-controls',
|
|
41
41
|
'@storybook/addon-ondevice-notes',
|
|
42
|
+
'@react-native-async-storage/async-storage',
|
|
43
|
+
'react-native-safe-area-context',
|
|
42
44
|
]
|
|
43
45
|
)
|
|
44
46
|
);
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
yield { success: true };
|
|
49
|
-
} finally {
|
|
50
|
-
if (childProcess) {
|
|
51
|
-
childProcess.kill();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
48
|
+
runCliStorybook(context.root, options);
|
|
49
|
+
yield { success: true };
|
|
54
50
|
}
|
|
55
51
|
|
|
56
|
-
function runCliStorybook(
|
|
52
|
+
export function runCliStorybook(
|
|
57
53
|
workspaceRoot: string,
|
|
58
54
|
options: ReactNativeStorybookOptions
|
|
59
55
|
) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
createStorybookOptions(options),
|
|
67
|
-
{
|
|
68
|
-
cwd: workspaceRoot,
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
// Ensure the child process is killed when the parent exits
|
|
73
|
-
process.on('exit', () => childProcess.kill());
|
|
74
|
-
process.on('SIGTERM', () => childProcess.kill());
|
|
56
|
+
const storiesFiles: string[] = options.searchDir.flatMap((dir) =>
|
|
57
|
+
globSync(join(dir, options.pattern))
|
|
58
|
+
);
|
|
59
|
+
if (storiesFiles.length === 0) {
|
|
60
|
+
logger.warn(`${chalk.bold.yellow('warn')} No stories found.`);
|
|
61
|
+
}
|
|
75
62
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
reject(code);
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
}
|
|
63
|
+
const newContents = `// Auto-generated file created by nx
|
|
64
|
+
// DO NOT EDIT.
|
|
65
|
+
export function loadStories() {
|
|
66
|
+
return [
|
|
67
|
+
${storiesFiles.map((story) => `require('${story}')`).join(',\n')}
|
|
68
|
+
];
|
|
69
|
+
}`;
|
|
88
70
|
|
|
89
|
-
|
|
90
|
-
return Object.keys(options).reduce((acc, k) => {
|
|
91
|
-
const v = options[k];
|
|
92
|
-
if (typeof v === 'boolean') {
|
|
93
|
-
if (v === true) {
|
|
94
|
-
acc.push(`--${k}`);
|
|
95
|
-
}
|
|
96
|
-
} else if (Array.isArray(v)) {
|
|
97
|
-
v.forEach((value) => {
|
|
98
|
-
acc.push(`--${k}`, value);
|
|
99
|
-
});
|
|
100
|
-
} else {
|
|
101
|
-
acc.push(`--${k}`, v);
|
|
102
|
-
}
|
|
103
|
-
return acc;
|
|
104
|
-
}, []);
|
|
71
|
+
writeFileSync(join(workspaceRoot, options.outputFile), newContents);
|
|
105
72
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
|
-
import * as ts from 'typescript';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type * as ts from 'typescript';
|
|
3
|
+
export interface CreateComponentStoriesFileSchema {
|
|
4
|
+
project: string;
|
|
5
|
+
componentPath: string;
|
|
6
|
+
skipFormat?: boolean;
|
|
7
|
+
}
|
|
5
8
|
export declare function createComponentStoriesFile(host: Tree, { project, componentPath }: CreateComponentStoriesFileSchema): void;
|
|
9
|
+
export declare function findPropsAndGenerateFile(host: Tree, sourceFile: ts.SourceFile, cmpDeclaration: ts.Node, componentDirectory: string, name: string, isPlainJs: boolean, fileExt: string, fromNodeArray?: boolean): void;
|
|
6
10
|
export declare function componentStoryGenerator(host: Tree, schema: CreateComponentStoriesFileSchema): Promise<void>;
|
|
7
11
|
export default componentStoryGenerator;
|
|
8
12
|
export declare const componentStorySchematic: (generatorOptions: CreateComponentStoriesFileSchema) => (tree: any, context: any) => Promise<any>;
|
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.componentStorySchematic = exports.componentStoryGenerator = exports.
|
|
3
|
+
exports.componentStorySchematic = exports.componentStoryGenerator = exports.findPropsAndGenerateFile = exports.createComponentStoriesFile = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const ts = require("typescript");
|
|
7
6
|
const ast_utils_1 = require("@nx/react/src/utils/ast-utils");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
[ts.SyntaxKind.NumberKeyword]: 0,
|
|
12
|
-
[ts.SyntaxKind.BooleanKeyword]: false,
|
|
13
|
-
};
|
|
14
|
-
const resolvedValue = typeNameToDefault[property];
|
|
15
|
-
if (typeof resolvedValue === undefined) {
|
|
16
|
-
return "''";
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
return resolvedValue;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.getArgsDefaultValue = getArgsDefaultValue;
|
|
7
|
+
const component_props_1 = require("@nx/react/src/utils/component-props");
|
|
8
|
+
const ensure_typescript_1 = require("@nx/js/src/utils/typescript/ensure-typescript");
|
|
9
|
+
let tsModule;
|
|
23
10
|
function createComponentStoriesFile(host, { project, componentPath }) {
|
|
11
|
+
if (!tsModule) {
|
|
12
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
13
|
+
}
|
|
24
14
|
const proj = (0, devkit_1.getProjects)(host).get(project);
|
|
25
15
|
const sourceRoot = proj.sourceRoot;
|
|
26
16
|
const componentFilePath = (0, devkit_1.joinPathFragments)(sourceRoot, componentPath);
|
|
@@ -43,7 +33,7 @@ function createComponentStoriesFile(host, { project, componentPath }) {
|
|
|
43
33
|
if (contents === null) {
|
|
44
34
|
throw new Error(`Failed to read ${componentFilePath}`);
|
|
45
35
|
}
|
|
46
|
-
const sourceFile =
|
|
36
|
+
const sourceFile = tsModule.createSourceFile(componentFilePath, contents, tsModule.ScriptTarget.Latest, true);
|
|
47
37
|
const cmpDeclaration = (0, ast_utils_1.getComponentNode)(sourceFile);
|
|
48
38
|
if (!cmpDeclaration) {
|
|
49
39
|
const componentNodes = (0, ast_utils_1.findExportDeclarationsForJsx)(sourceFile);
|
|
@@ -62,29 +52,7 @@ function createComponentStoriesFile(host, { project, componentPath }) {
|
|
|
62
52
|
}
|
|
63
53
|
exports.createComponentStoriesFile = createComponentStoriesFile;
|
|
64
54
|
function findPropsAndGenerateFile(host, sourceFile, cmpDeclaration, componentDirectory, name, isPlainJs, fileExt, fromNodeArray) {
|
|
65
|
-
const
|
|
66
|
-
let propsTypeName = null;
|
|
67
|
-
let props = [];
|
|
68
|
-
let argTypes = [];
|
|
69
|
-
if (propsInterface) {
|
|
70
|
-
propsTypeName = propsInterface.name.text;
|
|
71
|
-
props = propsInterface.members.map((member) => {
|
|
72
|
-
if (member.type.kind === ts.SyntaxKind.FunctionType) {
|
|
73
|
-
argTypes.push({
|
|
74
|
-
name: member.name.text,
|
|
75
|
-
type: 'action',
|
|
76
|
-
actionText: `${member.name.text} executed!`,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
return {
|
|
81
|
-
name: member.name.text,
|
|
82
|
-
defaultValue: getArgsDefaultValue(member.type.kind),
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
props = props.filter((p) => p && p.defaultValue !== undefined);
|
|
87
|
-
}
|
|
55
|
+
const { propsTypeName, props, argTypes } = (0, component_props_1.getDefaultsForComponent)(sourceFile, cmpDeclaration);
|
|
88
56
|
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files'), (0, devkit_1.normalizePath)(componentDirectory), {
|
|
89
57
|
componentFileName: fromNodeArray
|
|
90
58
|
? `${name}--${cmpDeclaration.name.text}`
|
|
@@ -96,9 +64,9 @@ function findPropsAndGenerateFile(host, sourceFile, cmpDeclaration, componentDir
|
|
|
96
64
|
componentName: cmpDeclaration.name.text,
|
|
97
65
|
isPlainJs,
|
|
98
66
|
fileExt,
|
|
99
|
-
hasActions: argTypes && argTypes.length,
|
|
100
67
|
});
|
|
101
68
|
}
|
|
69
|
+
exports.findPropsAndGenerateFile = findPropsAndGenerateFile;
|
|
102
70
|
function componentStoryGenerator(host, schema) {
|
|
103
71
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
104
72
|
createComponentStoriesFile(host, schema);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-story.js","sourceRoot":"","sources":["../../../../../../packages/react-native/src/generators/component-story/component-story.ts"],"names":[],"mappings":";;;;AAAA,uCAQoB;
|
|
1
|
+
{"version":3,"file":"component-story.js","sourceRoot":"","sources":["../../../../../../packages/react-native/src/generators/component-story/component-story.ts"],"names":[],"mappings":";;;;AAAA,uCAQoB;AAEpB,6DAGuC;AACvC,yEAA8E;AAC9E,qFAAiF;AAEjF,IAAI,QAAqC,CAAC;AAQ1C,SAAgB,0BAA0B,CACxC,IAAU,EACV,EAAE,OAAO,EAAE,aAAa,EAAoC;IAE5D,IAAI,CAAC,QAAQ,EAAE;QACb,QAAQ,GAAG,IAAA,oCAAgB,GAAE,CAAC;KAC/B;IACD,MAAM,IAAI,GAAG,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;IAEnC,MAAM,iBAAiB,GAAG,IAAA,0BAAiB,EAAC,UAAU,EAAE,aAAa,CAAC,CAAC;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V,MAAwC;;QAExC,0BAA0B,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAEzC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;YACtB,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;SACzB;IACH,CAAC;CAAA;AATD,0DASC;AAED,kBAAe,uBAAuB,CAAC;AAC1B,QAAA,uBAAuB,GAAG,IAAA,2BAAkB,EACvD,uBAAuB,CACxB,CAAC"}
|
|
@@ -56,12 +56,14 @@ describe('react-native:component-story', () => {
|
|
|
56
56
|
expect(
|
|
57
57
|
formatFile`${appTree.read(storyFilePath, 'utf-8').replace('·', '')}`
|
|
58
58
|
).toContain(formatFile`
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
import type { Meta } from '@storybook/react-native';
|
|
60
|
+
import { TestUiLib } from './test-ui-lib';
|
|
61
|
+
const Story: Meta<typeof TestUiLib> = {
|
|
62
|
+
component: TestUiLib,
|
|
63
|
+
title: 'TestUiLib',
|
|
64
|
+
};
|
|
65
|
+
export default Story;
|
|
66
|
+
export const Primary = { args: {} };
|
|
65
67
|
`);
|
|
66
68
|
});
|
|
67
69
|
});
|
|
@@ -102,14 +104,9 @@ describe('react-native:component-story', () => {
|
|
|
102
104
|
it('should properly set up the story', () => {
|
|
103
105
|
expect(formatFile`${appTree.read(storyFilePathPlain, 'utf-8')}`)
|
|
104
106
|
.toContain(formatFile`
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const props = {};
|
|
110
|
-
|
|
111
|
-
storiesOf('Test', module)
|
|
112
|
-
.add('Primary', () => <Test {...props} />);
|
|
107
|
+
import Test from './test-ui-libplain';
|
|
108
|
+
export default { component: Test, title: 'Test' };
|
|
109
|
+
export const Primary = { args: {} };
|
|
113
110
|
`);
|
|
114
111
|
});
|
|
115
112
|
});
|
|
@@ -142,12 +139,11 @@ describe('react-native:component-story', () => {
|
|
|
142
139
|
it('should create a story without controls', () => {
|
|
143
140
|
expect(formatFile`${appTree.read(storyFilePath, 'utf-8')}`)
|
|
144
141
|
.toContain(formatFile`
|
|
145
|
-
import {
|
|
146
|
-
import React from 'react';
|
|
142
|
+
import type { Meta } from '@storybook/react-native';
|
|
147
143
|
import { Test } from './test-ui-lib';
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
144
|
+
const Story: Meta<typeof Test> = { component: Test, title: 'Test' };
|
|
145
|
+
export default Story;
|
|
146
|
+
export const Primary = { args: {} };
|
|
151
147
|
`);
|
|
152
148
|
});
|
|
153
149
|
});
|
|
@@ -164,12 +160,14 @@ describe('react-native:component-story', () => {
|
|
|
164
160
|
expect(
|
|
165
161
|
formatFile`${appTree.read(storyFilePath, 'utf-8').replace('·', '')}`
|
|
166
162
|
).toContain(formatFile`
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
163
|
+
import type { Meta } from '@storybook/react-native';
|
|
164
|
+
import { TestUiLib } from './test-ui-lib';
|
|
165
|
+
const Story: Meta<typeof TestUiLib> = {
|
|
166
|
+
component: TestUiLib,
|
|
167
|
+
title: 'TestUiLib',
|
|
168
|
+
};
|
|
169
|
+
export default Story;
|
|
170
|
+
export const Primary = { args: {} };
|
|
173
171
|
`);
|
|
174
172
|
});
|
|
175
173
|
});
|
|
@@ -212,14 +210,15 @@ describe('react-native:component-story', () => {
|
|
|
212
210
|
expect(
|
|
213
211
|
formatFile`${appTree.read(storyFilePath, 'utf-8').replace('·', '')}`
|
|
214
212
|
).toContain(formatFile`
|
|
215
|
-
import {
|
|
216
|
-
import {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
213
|
+
import type { Meta } from '@storybook/react-native';
|
|
214
|
+
import { Test } from './test-ui-lib';
|
|
215
|
+
const Story: Meta<typeof Test> = {
|
|
216
|
+
component: Test,
|
|
217
|
+
title: 'Test',
|
|
218
|
+
argTypes: { someAction: { action: 'someAction executed!' } },
|
|
219
|
+
};
|
|
220
|
+
export default Story;
|
|
221
|
+
export const Primary = { args: { name: '', displayAge: false } };
|
|
223
222
|
`);
|
|
224
223
|
});
|
|
225
224
|
});
|
|
@@ -359,15 +358,11 @@ describe('react-native:component-story', () => {
|
|
|
359
358
|
expect(
|
|
360
359
|
formatFile`${appTree.read(storyFilePath, 'utf-8').replace('·', '')}`
|
|
361
360
|
).toContain(formatFile`
|
|
362
|
-
import {
|
|
363
|
-
import
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
displayAge: false,
|
|
368
|
-
};
|
|
369
|
-
storiesOf('Test', module)
|
|
370
|
-
.add('Primary', () => <Test {...props} />);
|
|
361
|
+
import type { Meta } from '@storybook/react-native';
|
|
362
|
+
import { Test } from './test-ui-lib';
|
|
363
|
+
const Story: Meta<typeof Test> = { component: Test, title: 'Test' };
|
|
364
|
+
export default Story;
|
|
365
|
+
export const Primary = { args: { name: '', displayAge: false } };
|
|
371
366
|
`);
|
|
372
367
|
});
|
|
373
368
|
});
|
|
@@ -391,14 +386,14 @@ describe('react-native:component-story', () => {
|
|
|
391
386
|
it('should properly set up the story', () => {
|
|
392
387
|
expect(formatFile`${appTree.read(storyFilePath, 'utf-8')}`)
|
|
393
388
|
.toContain(formatFile`
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
389
|
+
import type { Meta } from '@storybook/react-native';
|
|
390
|
+
import { TestUiLib } from './test-ui-lib';
|
|
391
|
+
const Story: Meta<typeof TestUiLib> = {
|
|
392
|
+
component: TestUiLib,
|
|
393
|
+
title: 'TestUiLib',
|
|
394
|
+
};
|
|
395
|
+
export default Story;
|
|
396
|
+
export const Primary = { args: {} };
|
|
402
397
|
`);
|
|
403
398
|
});
|
|
404
399
|
});
|
|
@@ -1,24 +1,32 @@
|
|
|
1
|
-
<% if (
|
|
2
|
-
|
|
3
|
-
<% } %>
|
|
4
|
-
import { storiesOf } from '@storybook/react-native';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import {
|
|
7
|
-
<%= componentName %>
|
|
8
|
-
<% if ( propsTypeName ) { %>, <%= propsTypeName %> <% } %>
|
|
9
|
-
} from './<%= componentImportFileName %>';
|
|
1
|
+
<% if ( !isPlainJs ) { %>import type { Meta } from '@storybook/react-native';<% } %>
|
|
2
|
+
import<% if ( !isPlainJs ) { %> { <% } %> <%= componentName %> <% if ( !isPlainJs ) { %> } <% } %> from './<%= componentImportFileName %>';
|
|
10
3
|
|
|
11
|
-
<% if (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
<% if ( isPlainJs ) { %>
|
|
5
|
+
export default {
|
|
6
|
+
component: <%= componentName %>,
|
|
7
|
+
title: '<%= componentName %>',<% if ( argTypes && argTypes.length > 0 ) { %>
|
|
8
|
+
argTypes: {<% for (let argType of argTypes) { %>
|
|
9
|
+
<%= argType.name %>: { <%- argType.type %> : "<%- argType.actionText %>" },<% } %>
|
|
10
|
+
}
|
|
11
|
+
<% } %>
|
|
12
|
+
};
|
|
15
13
|
<% } %>
|
|
16
14
|
|
|
17
|
-
const props <% if ( propsTypeName ) { %>:<%= propsTypeName %><% } %> = {<% for (let prop of props) { %>
|
|
18
|
-
<%= prop.name %>: <%- prop.defaultValue %>,
|
|
19
|
-
<% } %>};
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
)
|
|
16
|
+
<% if ( !isPlainJs ) { %>
|
|
17
|
+
const Story: Meta<typeof <%= componentName %>> = {
|
|
18
|
+
component: <%= componentName %>,
|
|
19
|
+
title: '<%= componentName %>',<% if ( argTypes && argTypes.length > 0 ) { %>
|
|
20
|
+
argTypes: {<% for (let argType of argTypes) { %>
|
|
21
|
+
<%= argType.name %>: { <%- argType.type %> : "<%- argType.actionText %>" },<% } %>
|
|
22
|
+
}
|
|
23
|
+
<% } %>
|
|
24
|
+
};
|
|
25
|
+
export default Story;
|
|
26
|
+
<% } %>
|
|
27
|
+
|
|
28
|
+
export const Primary = {
|
|
29
|
+
args: {<% for (let prop of props) { %>
|
|
30
|
+
<%= prop.name %>: <%- prop.defaultValue %>,<% } %>
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -30,6 +30,10 @@ function storybookConfigurationGenerator(host, schema) {
|
|
|
30
30
|
tsConfiguration: schema.tsConfiguration,
|
|
31
31
|
skipFormat: true,
|
|
32
32
|
});
|
|
33
|
+
const installRequiredPackagesTask = yield (0, devkit_1.addDependenciesToPackageJson)(host, {}, {
|
|
34
|
+
'@react-native-async-storage/async-storage': versions_1.reactNativeAsyncStorageVersion,
|
|
35
|
+
'react-native-safe-area-context': versions_1.reactNativeSafeAreaContextVersion,
|
|
36
|
+
});
|
|
33
37
|
addStorybookTask(host, schema.name);
|
|
34
38
|
(0, create_storybook_files_1.createStorybookFiles)(host, schema);
|
|
35
39
|
(0, replace_app_import_with_storybook_toggle_1.replaceAppImportWithStorybookToggle)(host, schema);
|
|
@@ -38,7 +42,7 @@ function storybookConfigurationGenerator(host, schema) {
|
|
|
38
42
|
yield generateStories(host, schema);
|
|
39
43
|
}
|
|
40
44
|
yield (0, devkit_1.formatFiles)(host);
|
|
41
|
-
return installTask;
|
|
45
|
+
return (0, devkit_1.runTasksInSerial)(installTask, installRequiredPackagesTask);
|
|
42
46
|
});
|
|
43
47
|
}
|
|
44
48
|
exports.storybookConfigurationGenerator = storybookConfigurationGenerator;
|
|
@@ -47,10 +51,9 @@ function addStorybookTask(host, projectName) {
|
|
|
47
51
|
projectConfig.targets['storybook'] = {
|
|
48
52
|
executor: '@nx/react-native:storybook',
|
|
49
53
|
options: {
|
|
50
|
-
searchDir: [projectConfig.
|
|
51
|
-
outputFile: './.storybook/story-loader.
|
|
54
|
+
searchDir: [projectConfig.sourceRoot],
|
|
55
|
+
outputFile: './.storybook/story-loader.ts',
|
|
52
56
|
pattern: '**/*.stories.@(js|jsx|ts|tsx|md)',
|
|
53
|
-
silent: false,
|
|
54
57
|
},
|
|
55
58
|
};
|
|
56
59
|
(0, devkit_1.updateProjectConfiguration)(host, projectName, projectConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../../../../packages/react-native/src/generators/storybook-configuration/configuration.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../../../../packages/react-native/src/generators/storybook-configuration/configuration.ts"],"names":[],"mappings":";;;;AAAA,uCAUoB;AACpB,mDAI8B;AAE9B,gDAAkD;AAClD,6GAAoG;AACpG,yEAAoE;AACpE,6GAAqG;AAIrG,SAAe,eAAe,CAAC,IAAU,EAAE,MAAgC;;QACzE,MAAM,IAAA,iBAAgB,EAAC,IAAI,EAAE;YAC3B,OAAO,EAAE,MAAM,CAAC,IAAI;YACpB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;IACL,CAAC;CAAA;AAED,SAAsB,+BAA+B,CACnD,IAAU,EACV,MAAgC;;QAEhC,MAAM,EAAE,sBAAsB,EAAE,GAAG,IAAA,sBAAa,EAE9C,eAAe,EAAE,oBAAS,CAAC,CAAC;QAE9B,MAAM,WAAW,GAAG,MAAM,sBAAsB,CAAC,IAAI,EAAE;YACrD,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,WAAW,EAAE,yBAAyB;YACtC,gBAAgB,EAAE,KAAK;YACvB,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;YACzC,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QAEH,MAAM,2BAA2B,GAAG,MAAM,IAAA,qCAA4B,EACpE,IAAI,EACJ,EAAE,EACF;YACE,2CAA2C,EACzC,yCAA8B;YAChC,gCAAgC,EAAE,4CAAiC;SACpE,CACF,CAAC;QAEF,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QACpC,IAAA,6CAAoB,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACnC,IAAA,8EAAmC,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAClD,IAAA,6EAAkC,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAEjD,IAAI,MAAM,CAAC,eAAe,EAAE;YAC1B,MAAM,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;SACrC;QAED,MAAM,IAAA,oBAAW,EAAC,IAAI,CAAC,CAAC;QACxB,OAAO,IAAA,yBAAgB,EAAC,WAAW,EAAE,2BAA2B,CAAC,CAAC;IACpE,CAAC;CAAA;AAxCD,0EAwCC;AAED,SAAS,gBAAgB,CAAC,IAAU,EAAE,WAAmB;IACvD,MAAM,aAAa,GAAG,IAAA,iCAAwB,EAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAClE,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG;QACnC,QAAQ,EAAE,4BAA4B;QACtC,OAAO,EAAE;YACP,SAAS,EAAE,CAAC,aAAa,CAAC,UAAU,CAAC;YACrC,UAAU,EAAE,8BAA8B;YAC1C,OAAO,EAAE,kCAAkC;SAC5C;KACF,CAAC;IAEF,IAAA,mCAA0B,EAAC,IAAI,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;AAC/D,CAAC;AAED,kBAAe,+BAA+B,CAAC;AAClC,QAAA,+BAA+B,GAAG,IAAA,2BAAkB,EAC/D,+BAA+B,CAChC,CAAC"}
|
|
@@ -20,15 +20,6 @@ describe('react-native:storybook-configuration', () => {
|
|
|
20
20
|
let appTree;
|
|
21
21
|
|
|
22
22
|
beforeEach(async () => {
|
|
23
|
-
// jest.spyOn(fileUtils, 'readPackageJson').mockReturnValue({
|
|
24
|
-
// devDependencies: {
|
|
25
|
-
// '@storybook/addon-essentials': '*',
|
|
26
|
-
// '@storybook/react-native': '*',
|
|
27
|
-
// '@storybook/addon-ondevice-actions': '*',
|
|
28
|
-
// '@storybook/addon-ondevice-knobs': '*',
|
|
29
|
-
// },
|
|
30
|
-
// });
|
|
31
|
-
|
|
32
23
|
jest.spyOn(logger, 'warn').mockImplementation(() => {});
|
|
33
24
|
jest.spyOn(logger, 'debug').mockImplementation(() => {});
|
|
34
25
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.update = void 0;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
/**
|
|
6
|
+
* This migration is to upgrade storybook to 6.5.
|
|
7
|
+
* - remove react-native-storybook-loader
|
|
8
|
+
* - change .storybook/story-loader.js to .storybook/story-loader.ts
|
|
9
|
+
*/
|
|
10
|
+
function update(tree) {
|
|
11
|
+
(0, devkit_1.updateJson)(tree, 'package.json', (packageJson) => {
|
|
12
|
+
delete packageJson.devDependencies['react-native-storybook-loader'];
|
|
13
|
+
return packageJson;
|
|
14
|
+
});
|
|
15
|
+
if (tree.exists('.storybook/story-loader.js')) {
|
|
16
|
+
tree.rename('.storybook/story-loader.js', '.storybook/story-loader.ts');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.update = update;
|
|
20
|
+
//# sourceMappingURL=upgrade-storybook-6-5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade-storybook-6-5.js","sourceRoot":"","sources":["../../../../../../packages/react-native/src/migrations/update-16-1-0/upgrade-storybook-6-5.ts"],"names":[],"mappings":";;;AAAA,uCAA8C;AAE9C;;;;GAIG;AACH,SAAgB,MAAM,CAAC,IAAU;IAC/B,IAAA,mBAAU,EAAC,IAAI,EAAE,cAAc,EAAE,CAAC,WAAW,EAAE,EAAE;QAC/C,OAAO,WAAW,CAAC,eAAe,CAAC,+BAA+B,CAAC,CAAC;QACpE,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC,CAAC;IACH,IAAI,IAAI,CAAC,MAAM,CAAC,4BAA4B,CAAC,EAAE;QAC7C,IAAI,CAAC,MAAM,CAAC,4BAA4B,EAAE,4BAA4B,CAAC,CAAC;KACzE;AACH,CAAC;AARD,wBAQC"}
|
|
@@ -52,13 +52,6 @@ function podInstall(iosDirectory, buildFolder) {
|
|
|
52
52
|
}
|
|
53
53
|
devkit_1.logger.info(stdout);
|
|
54
54
|
if (stdout.includes('Pod installation complete')) {
|
|
55
|
-
// Remove build folder after pod install
|
|
56
|
-
if (buildFolder) {
|
|
57
|
-
buildFolder = (0, path_1.join)(iosDirectory, buildFolder);
|
|
58
|
-
if ((0, fs_extra_1.existsSync)(buildFolder)) {
|
|
59
|
-
(0, fs_extra_1.rmdirSync)(buildFolder, { recursive: true });
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
55
|
resolve();
|
|
63
56
|
}
|
|
64
57
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pod-install-task.js","sourceRoot":"","sources":["../../../../../packages/react-native/src/utils/pod-install-task.ts"],"names":[],"mappings":";;;AAAA,iDAAqC;AACrC,2BAA8B;AAC9B,+BAA+B;AAC/B,uCAAuD;AACvD,uCAAiD;AACjD,+BAA4B;AAE5B,MAAM,sBAAsB,GAAG;UACrB,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC;;;;EAIjC,KAAK,CAAC,IAAI,CAAC,gCAAgC,CAAC;;;EAG5C,KAAK,CAAC,IAAI,CAAC,oDAAoD,CAAC;CACjE,CAAC;AAEF;;;;GAIG;AACH,SAAgB,aAAa,CAC3B,YAAoB,EACpB,UAAmB,IAAI,EACvB,WAAoB;IAEpB,OAAO,GAAG,EAAE;QACV,IAAI,IAAA,aAAQ,GAAE,KAAK,QAAQ,EAAE;YAC3B,eAAM,CAAC,IAAI,CAAC,+CAA+C,CAAC,CAAC;YAC7D,OAAO;SACR;QAED,IAAI,CAAC,OAAO,IAAI,CAAC,IAAA,qBAAU,EAAC,IAAA,WAAI,EAAC,YAAY,EAAE,SAAS,CAAC,CAAC,EAAE;YAC1D,eAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;YACtC,OAAO;SACR;QAED,eAAM,CAAC,IAAI,CAAC,iCAAiC,YAAY,GAAG,CAAC,CAAC;QAE9D,OAAO,UAAU,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IAC/C,CAAC,CAAC;AACJ,CAAC;AApBD,sCAoBC;AAED,SAAgB,UAAU,CACxB,YAAoB,EACpB,WAAoB;IAEpB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAA,oBAAI,EACF,aAAa,EACb;YACE,GAAG,EAAE,YAAY;SAClB,EACD,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YACxB,IAAI,KAAK,EAAE;gBACT,eAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;gBAC5B,MAAM,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC;aAC3C;YACD,IAAI,MAAM,EAAE;gBACV,eAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;gBACrB,MAAM,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC;aAC3C;YACD,eAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACpB,IAAI,MAAM,CAAC,QAAQ,CAAC,2BAA2B,CAAC,EAAE;gBAChD,
|
|
1
|
+
{"version":3,"file":"pod-install-task.js","sourceRoot":"","sources":["../../../../../packages/react-native/src/utils/pod-install-task.ts"],"names":[],"mappings":";;;AAAA,iDAAqC;AACrC,2BAA8B;AAC9B,+BAA+B;AAC/B,uCAAuD;AACvD,uCAAiD;AACjD,+BAA4B;AAE5B,MAA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B,CAAC,CAAC,CAAC;aAC3C;YACD,eAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACpB,IAAI,MAAM,CAAC,QAAQ,CAAC,2BAA2B,CAAC,EAAE;gBAChD,OAAO,EAAE,CAAC;aACX;iBAAM;gBACL,MAAM,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC;aAC3C;QACH,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AA5BD,gCA4BC"}
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -16,3 +16,5 @@ export declare const jestReactNativeVersion = "18.0.0";
|
|
|
16
16
|
export declare const reactNativeSvgTransformerVersion = "1.0.0";
|
|
17
17
|
export declare const reactNativeSvgVersion = "13.9.0";
|
|
18
18
|
export declare const babelRuntimeVersion = "7.21.0";
|
|
19
|
+
export declare const reactNativeAsyncStorageVersion = "1.18.1";
|
|
20
|
+
export declare const reactNativeSafeAreaContextVersion = "4.5.1";
|
package/src/utils/versions.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.babelRuntimeVersion = exports.reactNativeSvgVersion = exports.reactNativeSvgTransformerVersion = exports.jestReactNativeVersion = exports.testingLibraryJestNativeVersion = exports.testingLibraryReactNativeVersion = exports.typesReactVersion = exports.reactTestRendererVersion = exports.reactDomVersion = exports.reactVersion = exports.reactNativeCommunityCliAndroid = exports.reactNativeCommunityCliIos = exports.reactNativeCommunityCli = exports.metroVersion = exports.typesNodeVersion = exports.typesReactNativeVersion = exports.reactNativeVersion = exports.nxVersion = void 0;
|
|
3
|
+
exports.reactNativeSafeAreaContextVersion = exports.reactNativeAsyncStorageVersion = exports.babelRuntimeVersion = exports.reactNativeSvgVersion = exports.reactNativeSvgTransformerVersion = exports.jestReactNativeVersion = exports.testingLibraryJestNativeVersion = exports.testingLibraryReactNativeVersion = exports.typesReactVersion = exports.reactTestRendererVersion = exports.reactDomVersion = exports.reactVersion = exports.reactNativeCommunityCliAndroid = exports.reactNativeCommunityCliIos = exports.reactNativeCommunityCli = exports.metroVersion = exports.typesNodeVersion = exports.typesReactNativeVersion = exports.reactNativeVersion = exports.nxVersion = void 0;
|
|
4
4
|
exports.nxVersion = require('../../package.json').version;
|
|
5
5
|
exports.reactNativeVersion = '0.71.7';
|
|
6
6
|
exports.typesReactNativeVersion = '0.71.6';
|
|
@@ -19,4 +19,6 @@ exports.jestReactNativeVersion = '18.0.0';
|
|
|
19
19
|
exports.reactNativeSvgTransformerVersion = '1.0.0';
|
|
20
20
|
exports.reactNativeSvgVersion = '13.9.0';
|
|
21
21
|
exports.babelRuntimeVersion = '7.21.0';
|
|
22
|
+
exports.reactNativeAsyncStorageVersion = '1.18.1';
|
|
23
|
+
exports.reactNativeSafeAreaContextVersion = '4.5.1';
|
|
22
24
|
//# sourceMappingURL=versions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../../../packages/react-native/src/utils/versions.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC;AAElD,QAAA,kBAAkB,GAAG,QAAQ,CAAC;AAC9B,QAAA,uBAAuB,GAAG,QAAQ,CAAC;AAEnC,QAAA,gBAAgB,GAAG,SAAS,CAAC;AAE7B,QAAA,YAAY,GAAG,QAAQ,CAAC;AAExB,QAAA,uBAAuB,GAAG,QAAQ,CAAC;AACnC,QAAA,0BAA0B,GAAG,QAAQ,CAAC;AACtC,QAAA,8BAA8B,GAAG,QAAQ,CAAC;AAE1C,QAAA,YAAY,GAAG,QAAQ,CAAC;AACxB,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,wBAAwB,GAAG,QAAQ,CAAC;AACpC,QAAA,iBAAiB,GAAG,SAAS,CAAC;AAE9B,QAAA,gCAAgC,GAAG,QAAQ,CAAC;AAC5C,QAAA,+BAA+B,GAAG,OAAO,CAAC;AAE1C,QAAA,sBAAsB,GAAG,QAAQ,CAAC;AAElC,QAAA,gCAAgC,GAAG,OAAO,CAAC;AAC3C,QAAA,qBAAqB,GAAG,QAAQ,CAAC;AAEjC,QAAA,mBAAmB,GAAG,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../../../packages/react-native/src/utils/versions.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,CAAC;AAElD,QAAA,kBAAkB,GAAG,QAAQ,CAAC;AAC9B,QAAA,uBAAuB,GAAG,QAAQ,CAAC;AAEnC,QAAA,gBAAgB,GAAG,SAAS,CAAC;AAE7B,QAAA,YAAY,GAAG,QAAQ,CAAC;AAExB,QAAA,uBAAuB,GAAG,QAAQ,CAAC;AACnC,QAAA,0BAA0B,GAAG,QAAQ,CAAC;AACtC,QAAA,8BAA8B,GAAG,QAAQ,CAAC;AAE1C,QAAA,YAAY,GAAG,QAAQ,CAAC;AACxB,QAAA,eAAe,GAAG,QAAQ,CAAC;AAC3B,QAAA,wBAAwB,GAAG,QAAQ,CAAC;AACpC,QAAA,iBAAiB,GAAG,SAAS,CAAC;AAE9B,QAAA,gCAAgC,GAAG,QAAQ,CAAC;AAC5C,QAAA,+BAA+B,GAAG,OAAO,CAAC;AAE1C,QAAA,sBAAsB,GAAG,QAAQ,CAAC;AAElC,QAAA,gCAAgC,GAAG,OAAO,CAAC;AAC3C,QAAA,qBAAqB,GAAG,QAAQ,CAAC;AAEjC,QAAA,mBAAmB,GAAG,QAAQ,CAAC;AAE/B,QAAA,8BAA8B,GAAG,QAAQ,CAAC;AAC1C,QAAA,iCAAiC,GAAG,OAAO,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Auto-generated file created by react-native-storybook-loader
|
|
2
|
-
// Do not edit.
|
|
3
|
-
//
|
|
4
|
-
// https://github.com/elderfo/react-native-storybook-loader.git
|
|
5
|
-
|
|
6
|
-
function loadStories() {}
|
|
7
|
-
|
|
8
|
-
const stories = [];
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
loadStories,
|
|
12
|
-
stories,
|
|
13
|
-
};
|