@nx/react-native 16.8.0-beta.4 → 16.8.0-beta.5
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 +10 -10
- package/plugins/metro-resolver.js +4 -5
- package/plugins/with-nx-metro.js +23 -27
- package/src/executors/build-android/build-android.impl.js +6 -9
- package/src/executors/build-ios/build-ios.impl.js +8 -11
- package/src/executors/bundle/bundle.impl.js +6 -9
- package/src/executors/ensure-symlink/ensure-symlink.impl.js +4 -7
- package/src/executors/pod-install/pod-install.impl.js +5 -8
- package/src/executors/run-android/run-android.impl.js +23 -39
- package/src/executors/run-ios/run-ios.impl.js +25 -41
- package/src/executors/start/lib/is-packager-running.js +9 -12
- package/src/executors/start/start.impl.js +38 -43
- package/src/executors/storybook/storybook.impl.js +17 -20
- package/src/executors/sync-deps/sync-deps.impl.js +32 -37
- package/src/generators/application/application.js +23 -21
- package/src/generators/application/application.spec.ts +41 -38
- package/src/generators/application/lib/add-detox.js +15 -7
- package/src/generators/application/lib/add-project.js +4 -2
- package/src/generators/application/lib/create-application-files.js +6 -1
- package/src/generators/application/lib/nomalize-options.spec.ts +30 -25
- package/src/generators/application/lib/normalize-options.js +30 -23
- package/src/generators/component/component.js +9 -9
- package/src/generators/component/component.spec.ts +14 -22
- package/src/generators/component/lib/normalize-options.js +36 -37
- package/src/generators/component-story/component-story.js +6 -9
- package/src/generators/component-story/component-story.spec.ts +7 -7
- package/src/generators/init/init.js +56 -29
- package/src/generators/init/init.spec.ts +1 -1
- package/src/generators/library/lib/normalize-options.js +21 -18
- package/src/generators/library/library.js +94 -79
- package/src/generators/library/library.spec.ts +47 -57
- package/src/generators/stories/stories-app.spec.ts +20 -37
- package/src/generators/stories/stories-lib.spec.ts +10 -18
- package/src/generators/stories/stories.js +39 -44
- package/src/generators/storybook-configuration/configuration.js +29 -34
- package/src/generators/storybook-configuration/configuration.spec.ts +10 -12
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.js +1 -1
- package/src/generators/storybook-configuration/lib/add-resolver-main-fields-to-metro-config.spec.ts +7 -7
- package/src/generators/storybook-configuration/lib/create-storybook-files.js +30 -34
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.js +1 -1
- package/src/generators/storybook-configuration/lib/replace-app-import-with-storybook-toggle.spec.ts +7 -7
- package/src/generators/upgrade-native/upgrade-native.js +13 -16
- package/src/migrations/update-12-10-0/add-react-native-svg-12-10-0.js +11 -16
- package/src/migrations/update-12-5-0/update-jest-for-react-native.js +5 -8
- package/src/migrations/update-13-5-0/add-babel-config-root-13-5-0.js +12 -15
- package/src/migrations/update-13-5-0/update-react-native-typing-svg-13-5-0.js +7 -11
- package/src/migrations/update-14-0-0/add-project-root-metro-config-14-0-0.js +16 -20
- package/src/migrations/update-14-0-0/update-entry-file-bundle-14-0-0.js +23 -28
- package/src/migrations/update-14-0-2/change-main-to-class-name-14-0-2.js +26 -30
- package/src/migrations/update-14-2-1/rename-blockList-metro-config.js +16 -20
- package/src/migrations/update-14-5-5/add-exclude-sync-deps.js +12 -16
- package/src/migrations/update-14-5-8/change-searchDir-storybook.js +12 -16
- package/src/migrations/update-14-6-0/remove-jest-transform.js +13 -17
- package/src/migrations/update-15-0-0/add-babel-inputs.js +3 -6
- package/src/migrations/update-15-9-1/add-build-ios-target.js +19 -23
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +3 -6
- package/src/migrations/update-16-1-0/upgrade-storybook-6-5.js +2 -3
- package/src/migrations/update-16-6-0/add-depends-on.js +29 -33
- package/src/migrations/update-16-6-0/update-metro-config.js +11 -15
- package/src/utils/add-jest.js +19 -22
- package/src/utils/add-linting.js +26 -29
- package/src/utils/chmod-android-gradle-files.js +1 -1
- package/src/utils/find-all-npm-dependencies.js +1 -2
- package/src/utils/symlink-task.js +1 -1
- package/src/utils/testing-generators.js +19 -23
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.reactNativeLibrarySchematic = exports.reactNativeLibraryGeneratorInternal = exports.reactNativeLibraryGenerator = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
4
|
const devkit_1 = require("@nx/devkit");
|
|
6
5
|
const js_1 = require("@nx/js");
|
|
7
6
|
const init_1 = require("../init/init");
|
|
@@ -9,100 +8,116 @@ const add_linting_1 = require("../../utils/add-linting");
|
|
|
9
8
|
const add_jest_1 = require("../../utils/add-jest");
|
|
10
9
|
const versions_1 = require("../../utils/versions");
|
|
11
10
|
const normalize_options_1 = require("./lib/normalize-options");
|
|
12
|
-
function reactNativeLibraryGenerator(host, schema) {
|
|
13
|
-
return
|
|
14
|
-
|
|
11
|
+
async function reactNativeLibraryGenerator(host, schema) {
|
|
12
|
+
return await reactNativeLibraryGeneratorInternal(host, {
|
|
13
|
+
projectNameAndRootFormat: 'derived',
|
|
14
|
+
...schema,
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
exports.reactNativeLibraryGenerator = reactNativeLibraryGenerator;
|
|
18
|
-
function reactNativeLibraryGeneratorInternal(host, schema) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!options.skipTsConfig) {
|
|
42
|
-
(0, js_1.addTsConfigPath)(host, options.importPath, [
|
|
43
|
-
(0, devkit_1.joinPathFragments)(options.projectRoot, './src', 'index.' + (options.js ? 'js' : 'ts')),
|
|
44
|
-
]);
|
|
45
|
-
}
|
|
46
|
-
if (!options.skipFormat) {
|
|
47
|
-
yield (0, devkit_1.formatFiles)(host);
|
|
48
|
-
}
|
|
49
|
-
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
18
|
+
async function reactNativeLibraryGeneratorInternal(host, schema) {
|
|
19
|
+
const options = await (0, normalize_options_1.normalizeOptions)(host, schema);
|
|
20
|
+
if (options.publishable === true && !schema.importPath) {
|
|
21
|
+
throw new Error(`For publishable libs you have to provide a proper "--importPath" which needs to be a valid npm package name (e.g. my-awesome-lib or @myorg/my-lib)`);
|
|
22
|
+
}
|
|
23
|
+
const tasks = [];
|
|
24
|
+
const initTask = await (0, init_1.default)(host, {
|
|
25
|
+
...options,
|
|
26
|
+
skipFormat: true,
|
|
27
|
+
e2eTestRunner: 'none',
|
|
28
|
+
});
|
|
29
|
+
tasks.push(initTask);
|
|
30
|
+
const addProjectTask = await addProject(host, options);
|
|
31
|
+
if (addProjectTask) {
|
|
32
|
+
tasks.push(addProjectTask);
|
|
33
|
+
}
|
|
34
|
+
createFiles(host, options);
|
|
35
|
+
const lintTask = await (0, add_linting_1.addLinting)(host, {
|
|
36
|
+
...options,
|
|
37
|
+
projectName: options.name,
|
|
38
|
+
tsConfigPaths: [
|
|
39
|
+
(0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.lib.json'),
|
|
40
|
+
],
|
|
50
41
|
});
|
|
42
|
+
tasks.push(lintTask);
|
|
43
|
+
const jestTask = await (0, add_jest_1.addJest)(host, options.unitTestRunner, options.name, options.projectRoot, options.js, options.skipPackageJson);
|
|
44
|
+
tasks.push(jestTask);
|
|
45
|
+
if (options.publishable || options.buildable) {
|
|
46
|
+
updateLibPackageNpmScope(host, options);
|
|
47
|
+
}
|
|
48
|
+
if (!options.skipTsConfig) {
|
|
49
|
+
(0, js_1.addTsConfigPath)(host, options.importPath, [
|
|
50
|
+
(0, devkit_1.joinPathFragments)(options.projectRoot, './src', 'index.' + (options.js ? 'js' : 'ts')),
|
|
51
|
+
]);
|
|
52
|
+
}
|
|
53
|
+
if (!options.skipFormat) {
|
|
54
|
+
await (0, devkit_1.formatFiles)(host);
|
|
55
|
+
}
|
|
56
|
+
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
51
57
|
}
|
|
52
58
|
exports.reactNativeLibraryGeneratorInternal = reactNativeLibraryGeneratorInternal;
|
|
53
|
-
function addProject(host, options) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
{
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
targets,
|
|
92
|
-
});
|
|
93
|
-
return task;
|
|
59
|
+
async function addProject(host, options) {
|
|
60
|
+
const targets = {};
|
|
61
|
+
let task;
|
|
62
|
+
if (options.publishable || options.buildable) {
|
|
63
|
+
const { rollupInitGenerator } = (0, devkit_1.ensurePackage)('@nx/rollup', versions_1.nxVersion);
|
|
64
|
+
const external = [
|
|
65
|
+
'react/jsx-runtime',
|
|
66
|
+
'react-native',
|
|
67
|
+
'react',
|
|
68
|
+
'react-dom',
|
|
69
|
+
];
|
|
70
|
+
targets.build = {
|
|
71
|
+
executor: '@nx/rollup:rollup',
|
|
72
|
+
outputs: ['{options.outputPath}'],
|
|
73
|
+
options: {
|
|
74
|
+
outputPath: `dist/${options.projectRoot}`,
|
|
75
|
+
tsConfig: `${options.projectRoot}/tsconfig.lib.json`,
|
|
76
|
+
project: `${options.projectRoot}/package.json`,
|
|
77
|
+
entryFile: maybeJs(options, `${options.projectRoot}/src/index.ts`),
|
|
78
|
+
external,
|
|
79
|
+
rollupConfig: `@nx/react/plugins/bundle-rollup`,
|
|
80
|
+
assets: [
|
|
81
|
+
{
|
|
82
|
+
glob: `${options.projectRoot}/README.md`,
|
|
83
|
+
input: '.',
|
|
84
|
+
output: '.',
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
task = await rollupInitGenerator(host, { ...options, skipFormat: true });
|
|
90
|
+
}
|
|
91
|
+
(0, devkit_1.addProjectConfiguration)(host, options.name, {
|
|
92
|
+
root: options.projectRoot,
|
|
93
|
+
sourceRoot: (0, devkit_1.joinPathFragments)(options.projectRoot, 'src'),
|
|
94
|
+
projectType: 'library',
|
|
95
|
+
tags: options.parsedTags,
|
|
96
|
+
targets,
|
|
94
97
|
});
|
|
98
|
+
return task;
|
|
95
99
|
}
|
|
96
100
|
function updateTsConfig(tree, options) {
|
|
97
101
|
(0, devkit_1.updateJson)(tree, (0, devkit_1.joinPathFragments)(options.projectRoot, 'tsconfig.json'), (json) => {
|
|
98
102
|
if (options.strict) {
|
|
99
|
-
json.compilerOptions =
|
|
103
|
+
json.compilerOptions = {
|
|
104
|
+
...json.compilerOptions,
|
|
105
|
+
forceConsistentCasingInFileNames: true,
|
|
106
|
+
strict: true,
|
|
107
|
+
noImplicitReturns: true,
|
|
108
|
+
noFallthroughCasesInSwitch: true,
|
|
109
|
+
};
|
|
100
110
|
}
|
|
101
111
|
return json;
|
|
102
112
|
});
|
|
103
113
|
}
|
|
104
114
|
function createFiles(host, options) {
|
|
105
|
-
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files/lib'), options.projectRoot,
|
|
115
|
+
(0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, './files/lib'), options.projectRoot, {
|
|
116
|
+
...options,
|
|
117
|
+
...(0, devkit_1.names)(options.name),
|
|
118
|
+
offsetFromRoot: (0, devkit_1.offsetFromRoot)(options.projectRoot),
|
|
119
|
+
rootTsConfigPath: (0, js_1.getRelativePathToRootTsConfig)(host, options.projectRoot),
|
|
120
|
+
});
|
|
106
121
|
if (!options.publishable && !options.buildable) {
|
|
107
122
|
host.delete(`${options.projectRoot}/package.json`);
|
|
108
123
|
}
|
|
@@ -19,10 +19,11 @@ describe('lib', () => {
|
|
|
19
19
|
skipTsConfig: false,
|
|
20
20
|
unitTestRunner: 'jest',
|
|
21
21
|
strict: true,
|
|
22
|
+
projectNameAndRootFormat: 'as-provided',
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
beforeEach(() => {
|
|
25
|
-
appTree = createTreeWithEmptyWorkspace(
|
|
26
|
+
appTree = createTreeWithEmptyWorkspace();
|
|
26
27
|
appTree.write('.gitignore', '');
|
|
27
28
|
});
|
|
28
29
|
|
|
@@ -30,13 +31,13 @@ describe('lib', () => {
|
|
|
30
31
|
it('should update project.json', async () => {
|
|
31
32
|
await libraryGenerator(appTree, { ...defaultSchema, tags: 'one,two' });
|
|
32
33
|
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
|
33
|
-
expect(projectConfiguration.root).toEqual('
|
|
34
|
+
expect(projectConfiguration.root).toEqual('my-lib');
|
|
34
35
|
expect(projectConfiguration.targets.build).toBeUndefined();
|
|
35
36
|
expect(projectConfiguration.targets.lint).toEqual({
|
|
36
37
|
executor: '@nx/linter:eslint',
|
|
37
38
|
outputs: ['{options.outputFile}'],
|
|
38
39
|
options: {
|
|
39
|
-
lintFilePatterns: ['
|
|
40
|
+
lintFilePatterns: ['my-lib/**/*.{ts,tsx,js,jsx}'],
|
|
40
41
|
},
|
|
41
42
|
});
|
|
42
43
|
expect(projectConfiguration.tags).toEqual(['one', 'two']);
|
|
@@ -46,7 +47,7 @@ describe('lib', () => {
|
|
|
46
47
|
await libraryGenerator(appTree, defaultSchema);
|
|
47
48
|
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
|
48
49
|
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
|
49
|
-
'
|
|
50
|
+
'my-lib/src/index.ts',
|
|
50
51
|
]);
|
|
51
52
|
});
|
|
52
53
|
|
|
@@ -57,7 +58,7 @@ describe('lib', () => {
|
|
|
57
58
|
|
|
58
59
|
const tsconfigJson = readJson(appTree, '/tsconfig.json');
|
|
59
60
|
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
|
60
|
-
'
|
|
61
|
+
'my-lib/src/index.ts',
|
|
61
62
|
]);
|
|
62
63
|
});
|
|
63
64
|
|
|
@@ -70,15 +71,15 @@ describe('lib', () => {
|
|
|
70
71
|
await libraryGenerator(appTree, defaultSchema);
|
|
71
72
|
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
|
72
73
|
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
|
73
|
-
'
|
|
74
|
+
'my-lib/src/index.ts',
|
|
74
75
|
]);
|
|
75
76
|
});
|
|
76
77
|
|
|
77
78
|
it('should create a local tsconfig.json', async () => {
|
|
78
79
|
await libraryGenerator(appTree, defaultSchema);
|
|
79
80
|
|
|
80
|
-
const tsconfigJson = readJson(appTree, '
|
|
81
|
-
expect(tsconfigJson.extends).toBe('
|
|
81
|
+
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.json');
|
|
82
|
+
expect(tsconfigJson.extends).toBe('../tsconfig.base.json');
|
|
82
83
|
expect(tsconfigJson.references).toEqual([
|
|
83
84
|
{
|
|
84
85
|
path: './tsconfig.lib.json',
|
|
@@ -102,19 +103,19 @@ describe('lib', () => {
|
|
|
102
103
|
|
|
103
104
|
await libraryGenerator(appTree, defaultSchema);
|
|
104
105
|
|
|
105
|
-
const tsconfigJson = readJson(appTree, '
|
|
106
|
-
expect(tsconfigJson.extends).toBe('
|
|
106
|
+
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.json');
|
|
107
|
+
expect(tsconfigJson.extends).toBe('../tsconfig.json');
|
|
107
108
|
});
|
|
108
109
|
|
|
109
110
|
it('should extend the local tsconfig.json with tsconfig.spec.json', async () => {
|
|
110
111
|
await libraryGenerator(appTree, defaultSchema);
|
|
111
|
-
const tsconfigJson = readJson(appTree, '
|
|
112
|
+
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.spec.json');
|
|
112
113
|
expect(tsconfigJson.extends).toEqual('./tsconfig.json');
|
|
113
114
|
});
|
|
114
115
|
|
|
115
116
|
it('should extend the local tsconfig.json with tsconfig.lib.json', async () => {
|
|
116
117
|
await libraryGenerator(appTree, defaultSchema);
|
|
117
|
-
const tsconfigJson = readJson(appTree, '
|
|
118
|
+
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.lib.json');
|
|
118
119
|
expect(tsconfigJson.extends).toEqual('./tsconfig.json');
|
|
119
120
|
});
|
|
120
121
|
});
|
|
@@ -126,10 +127,8 @@ describe('lib', () => {
|
|
|
126
127
|
directory: 'myDir',
|
|
127
128
|
tags: 'one',
|
|
128
129
|
});
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
'my-dir-my-lib'
|
|
132
|
-
);
|
|
130
|
+
|
|
131
|
+
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
|
133
132
|
expect(projectConfiguration).toMatchObject({
|
|
134
133
|
tags: ['one'],
|
|
135
134
|
});
|
|
@@ -137,13 +136,13 @@ describe('lib', () => {
|
|
|
137
136
|
await libraryGenerator(appTree, {
|
|
138
137
|
...defaultSchema,
|
|
139
138
|
name: 'myLib2',
|
|
140
|
-
directory: '
|
|
139
|
+
directory: 'myDir2',
|
|
141
140
|
tags: 'one,two',
|
|
142
141
|
});
|
|
143
142
|
|
|
144
143
|
const lib2ProjectConfiguration = readProjectConfiguration(
|
|
145
144
|
appTree,
|
|
146
|
-
'my-
|
|
145
|
+
'my-lib2'
|
|
147
146
|
);
|
|
148
147
|
expect(lib2ProjectConfiguration).toMatchObject({
|
|
149
148
|
tags: ['one', 'two'],
|
|
@@ -152,17 +151,14 @@ describe('lib', () => {
|
|
|
152
151
|
|
|
153
152
|
it('should update project.json', async () => {
|
|
154
153
|
await libraryGenerator(appTree, { ...defaultSchema, directory: 'myDir' });
|
|
155
|
-
const projectConfiguration = readProjectConfiguration(
|
|
156
|
-
appTree,
|
|
157
|
-
'my-dir-my-lib'
|
|
158
|
-
);
|
|
154
|
+
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
|
159
155
|
|
|
160
|
-
expect(projectConfiguration.root).toEqual('
|
|
156
|
+
expect(projectConfiguration.root).toEqual('my-dir');
|
|
161
157
|
expect(projectConfiguration.targets.lint).toEqual({
|
|
162
158
|
executor: '@nx/linter:eslint',
|
|
163
159
|
outputs: ['{options.outputFile}'],
|
|
164
160
|
options: {
|
|
165
|
-
lintFilePatterns: ['
|
|
161
|
+
lintFilePatterns: ['my-dir/**/*.{ts,tsx,js,jsx}'],
|
|
166
162
|
},
|
|
167
163
|
});
|
|
168
164
|
});
|
|
@@ -170,9 +166,9 @@ describe('lib', () => {
|
|
|
170
166
|
it('should update root tsconfig.base.json', async () => {
|
|
171
167
|
await libraryGenerator(appTree, { ...defaultSchema, directory: 'myDir' });
|
|
172
168
|
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
|
173
|
-
expect(tsconfigJson.compilerOptions.paths['@proj/my-
|
|
174
|
-
|
|
175
|
-
);
|
|
169
|
+
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
|
170
|
+
'my-dir/src/index.ts',
|
|
171
|
+
]);
|
|
176
172
|
expect(
|
|
177
173
|
tsconfigJson.compilerOptions.paths['my-dir-my-lib/*']
|
|
178
174
|
).toBeUndefined();
|
|
@@ -184,9 +180,9 @@ describe('lib', () => {
|
|
|
184
180
|
await libraryGenerator(appTree, { ...defaultSchema, directory: 'myDir' });
|
|
185
181
|
|
|
186
182
|
const tsconfigJson = readJson(appTree, '/tsconfig.json');
|
|
187
|
-
expect(tsconfigJson.compilerOptions.paths['@proj/my-
|
|
188
|
-
|
|
189
|
-
);
|
|
183
|
+
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
|
184
|
+
'my-dir/src/index.ts',
|
|
185
|
+
]);
|
|
190
186
|
expect(
|
|
191
187
|
tsconfigJson.compilerOptions.paths['my-dir-my-lib/*']
|
|
192
188
|
).toBeUndefined();
|
|
@@ -195,11 +191,8 @@ describe('lib', () => {
|
|
|
195
191
|
it('should create a local tsconfig.json', async () => {
|
|
196
192
|
await libraryGenerator(appTree, { ...defaultSchema, directory: 'myDir' });
|
|
197
193
|
|
|
198
|
-
const tsconfigJson = readJson(
|
|
199
|
-
|
|
200
|
-
'libs/my-dir/my-lib/tsconfig.json'
|
|
201
|
-
);
|
|
202
|
-
expect(tsconfigJson.extends).toBe('../../../tsconfig.base.json');
|
|
194
|
+
const tsconfigJson = readJson(appTree, 'my-dir/tsconfig.json');
|
|
195
|
+
expect(tsconfigJson.extends).toBe('../tsconfig.base.json');
|
|
203
196
|
expect(tsconfigJson.references).toEqual([
|
|
204
197
|
{
|
|
205
198
|
path: './tsconfig.lib.json',
|
|
@@ -215,11 +208,8 @@ describe('lib', () => {
|
|
|
215
208
|
|
|
216
209
|
await libraryGenerator(appTree, { ...defaultSchema, directory: 'myDir' });
|
|
217
210
|
|
|
218
|
-
const tsconfigJson = readJson(
|
|
219
|
-
|
|
220
|
-
'libs/my-dir/my-lib/tsconfig.json'
|
|
221
|
-
);
|
|
222
|
-
expect(tsconfigJson.extends).toBe('../../../tsconfig.json');
|
|
211
|
+
const tsconfigJson = readJson(appTree, 'my-dir/tsconfig.json');
|
|
212
|
+
expect(tsconfigJson.extends).toBe('../tsconfig.json');
|
|
223
213
|
});
|
|
224
214
|
});
|
|
225
215
|
|
|
@@ -230,14 +220,14 @@ describe('lib', () => {
|
|
|
230
220
|
unitTestRunner: 'none',
|
|
231
221
|
});
|
|
232
222
|
|
|
233
|
-
expect(appTree.exists('
|
|
234
|
-
expect(appTree.exists('
|
|
223
|
+
expect(appTree.exists('my-lib/tsconfig.spec.json')).toBeFalsy();
|
|
224
|
+
expect(appTree.exists('my-lib/jest.config.ts')).toBeFalsy();
|
|
235
225
|
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
|
236
226
|
expect(projectConfiguration.targets.test).toBeUndefined();
|
|
237
227
|
expect(projectConfiguration.targets.lint).toMatchObject({
|
|
238
228
|
executor: '@nx/linter:eslint',
|
|
239
229
|
options: {
|
|
240
|
-
lintFilePatterns: ['
|
|
230
|
+
lintFilePatterns: ['my-lib/**/*.{ts,tsx,js,jsx}'],
|
|
241
231
|
},
|
|
242
232
|
outputs: ['{options.outputFile}'],
|
|
243
233
|
});
|
|
@@ -249,12 +239,12 @@ describe('lib', () => {
|
|
|
249
239
|
unitTestRunner: 'jest',
|
|
250
240
|
});
|
|
251
241
|
|
|
252
|
-
expect(appTree.read('
|
|
242
|
+
expect(appTree.read('my-lib/tsconfig.spec.json', 'utf-8'))
|
|
253
243
|
.toMatchInlineSnapshot(`
|
|
254
244
|
"{
|
|
255
245
|
"extends": "./tsconfig.json",
|
|
256
246
|
"compilerOptions": {
|
|
257
|
-
"outDir": "
|
|
247
|
+
"outDir": "../dist/out-tsc",
|
|
258
248
|
"module": "commonjs",
|
|
259
249
|
"types": ["jest", "node"]
|
|
260
250
|
},
|
|
@@ -273,7 +263,7 @@ describe('lib', () => {
|
|
|
273
263
|
}
|
|
274
264
|
"
|
|
275
265
|
`);
|
|
276
|
-
expect(appTree.read('
|
|
266
|
+
expect(appTree.read('my-lib/jest.config.ts', 'utf-8'))
|
|
277
267
|
.toMatchInlineSnapshot(`
|
|
278
268
|
"module.exports = {
|
|
279
269
|
displayName: 'my-lib',
|
|
@@ -284,7 +274,7 @@ describe('lib', () => {
|
|
|
284
274
|
moduleNameMapper: {
|
|
285
275
|
'\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock',
|
|
286
276
|
},
|
|
287
|
-
coverageDirectory: '
|
|
277
|
+
coverageDirectory: '../coverage/my-lib',
|
|
288
278
|
};
|
|
289
279
|
"
|
|
290
280
|
`);
|
|
@@ -299,7 +289,7 @@ describe('lib', () => {
|
|
|
299
289
|
},
|
|
300
290
|
"executor": "@nx/jest:jest",
|
|
301
291
|
"options": {
|
|
302
|
-
"jestConfig": "
|
|
292
|
+
"jestConfig": "my-lib/jest.config.ts",
|
|
303
293
|
"passWithNoTests": true,
|
|
304
294
|
},
|
|
305
295
|
"outputs": [
|
|
@@ -338,10 +328,10 @@ describe('lib', () => {
|
|
|
338
328
|
outputs: ['{options.outputPath}'],
|
|
339
329
|
options: {
|
|
340
330
|
external: ['react/jsx-runtime', 'react-native', 'react', 'react-dom'],
|
|
341
|
-
entryFile: '
|
|
342
|
-
outputPath: 'dist/
|
|
343
|
-
project: '
|
|
344
|
-
tsConfig: '
|
|
331
|
+
entryFile: 'my-lib/src/index.ts',
|
|
332
|
+
outputPath: 'dist/my-lib',
|
|
333
|
+
project: 'my-lib/package.json',
|
|
334
|
+
tsConfig: 'my-lib/tsconfig.lib.json',
|
|
345
335
|
rollupConfig: '@nx/react/plugins/bundle-rollup',
|
|
346
336
|
},
|
|
347
337
|
});
|
|
@@ -370,9 +360,9 @@ describe('lib', () => {
|
|
|
370
360
|
importPath: '@proj/my-lib',
|
|
371
361
|
});
|
|
372
362
|
|
|
373
|
-
const packageJson = readJson(appTree, '
|
|
363
|
+
const packageJson = readJson(appTree, 'my-lib/package.json');
|
|
374
364
|
expect(packageJson.name).toEqual('@proj/my-lib');
|
|
375
|
-
expect(appTree.exists('
|
|
365
|
+
expect(appTree.exists('my-lib/.babelrc'));
|
|
376
366
|
});
|
|
377
367
|
});
|
|
378
368
|
|
|
@@ -383,7 +373,7 @@ describe('lib', () => {
|
|
|
383
373
|
js: true,
|
|
384
374
|
});
|
|
385
375
|
|
|
386
|
-
expect(appTree.exists('
|
|
376
|
+
expect(appTree.exists('my-lib/src/index.js')).toBe(true);
|
|
387
377
|
});
|
|
388
378
|
});
|
|
389
379
|
|
|
@@ -395,7 +385,7 @@ describe('lib', () => {
|
|
|
395
385
|
directory: 'myDir',
|
|
396
386
|
importPath: '@myorg/lib',
|
|
397
387
|
});
|
|
398
|
-
const packageJson = readJson(appTree, '
|
|
388
|
+
const packageJson = readJson(appTree, 'my-dir/package.json');
|
|
399
389
|
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
|
400
390
|
|
|
401
391
|
expect(packageJson.name).toBe('@myorg/lib');
|
|
@@ -435,7 +425,7 @@ describe('lib', () => {
|
|
|
435
425
|
...defaultSchema,
|
|
436
426
|
strict: false,
|
|
437
427
|
});
|
|
438
|
-
const tsconfigJson = readJson(appTree, '
|
|
428
|
+
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.json');
|
|
439
429
|
|
|
440
430
|
expect(
|
|
441
431
|
tsconfigJson.compilerOptions.forceConsistentCasingInFileNames
|
|
@@ -21,14 +21,10 @@ describe('react:stories for applications', () => {
|
|
|
21
21
|
project: 'test-ui-app',
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
expect(appTree.exists('
|
|
24
|
+
expect(appTree.exists('test-ui-app/src/app/App.tsx')).toBeTruthy();
|
|
25
|
+
expect(appTree.exists('test-ui-app/src/app/App.stories.tsx')).toBeTruthy();
|
|
25
26
|
expect(
|
|
26
|
-
appTree.exists('
|
|
27
|
-
).toBeTruthy();
|
|
28
|
-
expect(
|
|
29
|
-
appTree.exists(
|
|
30
|
-
'apps/test-ui-app/src/app/another-cmp/another-cmp.stories.tsx'
|
|
31
|
-
)
|
|
27
|
+
appTree.exists('test-ui-app/src/app/another-cmp/another-cmp.stories.tsx')
|
|
32
28
|
).toBeTruthy();
|
|
33
29
|
});
|
|
34
30
|
|
|
@@ -39,17 +35,13 @@ describe('react:stories for applications', () => {
|
|
|
39
35
|
});
|
|
40
36
|
await storiesGenerator(appTree, {
|
|
41
37
|
project: 'test-ui-app',
|
|
42
|
-
ignorePaths: ['
|
|
38
|
+
ignorePaths: ['test-ui-app/src/app/**'],
|
|
43
39
|
});
|
|
44
40
|
|
|
45
|
-
expect(appTree.exists('
|
|
41
|
+
expect(appTree.exists('test-ui-app/src/app/App.tsx')).toBeTruthy();
|
|
42
|
+
expect(appTree.exists('test-ui-app/src/app/App.stories.tsx')).toBeFalsy();
|
|
46
43
|
expect(
|
|
47
|
-
appTree.exists('
|
|
48
|
-
).toBeFalsy();
|
|
49
|
-
expect(
|
|
50
|
-
appTree.exists(
|
|
51
|
-
'apps/test-ui-app/src/app/another-cmp/another-cmp.stories.tsx'
|
|
52
|
-
)
|
|
44
|
+
appTree.exists('test-ui-app/src/app/another-cmp/another-cmp.stories.tsx')
|
|
53
45
|
).toBeFalsy();
|
|
54
46
|
});
|
|
55
47
|
|
|
@@ -61,18 +53,14 @@ describe('react:stories for applications', () => {
|
|
|
61
53
|
|
|
62
54
|
await storiesGenerator(appTree, {
|
|
63
55
|
project: 'test-ui-app',
|
|
64
|
-
ignorePaths: [
|
|
65
|
-
'apps/test-ui-app/src/app/another-new-cmp/another-new-cmp.tsx',
|
|
66
|
-
],
|
|
56
|
+
ignorePaths: ['test-ui-app/src/app/another-new-cmp/another-new-cmp.tsx'],
|
|
67
57
|
});
|
|
68
58
|
|
|
69
|
-
expect(appTree.exists('
|
|
70
|
-
expect(
|
|
71
|
-
appTree.exists('apps/test-ui-app/src/app/App.stories.tsx')
|
|
72
|
-
).toBeTruthy();
|
|
59
|
+
expect(appTree.exists('test-ui-app/src/app/App.tsx')).toBeTruthy();
|
|
60
|
+
expect(appTree.exists('test-ui-app/src/app/App.stories.tsx')).toBeTruthy();
|
|
73
61
|
expect(
|
|
74
62
|
appTree.exists(
|
|
75
|
-
'
|
|
63
|
+
'test-ui-app/src/app/another-new-cmp/another-new-cmp.stories.tsx'
|
|
76
64
|
)
|
|
77
65
|
).toBeFalsy();
|
|
78
66
|
});
|
|
@@ -89,23 +77,19 @@ describe('react:stories for applications', () => {
|
|
|
89
77
|
});
|
|
90
78
|
await storiesGenerator(appTree, {
|
|
91
79
|
project: 'test-ui-app',
|
|
92
|
-
ignorePaths: [
|
|
93
|
-
'apps/test-ui-app/src/app/another-new-cmp/another-new-cmp.tsx',
|
|
94
|
-
],
|
|
80
|
+
ignorePaths: ['test-ui-app/src/app/another-new-cmp/another-new-cmp.tsx'],
|
|
95
81
|
});
|
|
96
82
|
|
|
97
|
-
expect(appTree.exists('
|
|
98
|
-
expect(
|
|
99
|
-
appTree.exists('apps/test-ui-app/src/app/App.stories.tsx')
|
|
100
|
-
).toBeTruthy();
|
|
83
|
+
expect(appTree.exists('test-ui-app/src/app/App.tsx')).toBeTruthy();
|
|
84
|
+
expect(appTree.exists('test-ui-app/src/app/App.stories.tsx')).toBeTruthy();
|
|
101
85
|
expect(
|
|
102
86
|
appTree.exists(
|
|
103
|
-
'
|
|
87
|
+
'test-ui-app/src/app/another-new-cmp/comp-a/comp-a.stories.tsx'
|
|
104
88
|
)
|
|
105
89
|
).toBeTruthy();
|
|
106
90
|
expect(
|
|
107
91
|
appTree.exists(
|
|
108
|
-
'
|
|
92
|
+
'test-ui-app/src/app/another-new-cmp/another-new-cmp.stories.tsx'
|
|
109
93
|
)
|
|
110
94
|
).toBeFalsy();
|
|
111
95
|
});
|
|
@@ -113,7 +97,7 @@ describe('react:stories for applications', () => {
|
|
|
113
97
|
it('should ignore files that do not contain components', async () => {
|
|
114
98
|
// create another component
|
|
115
99
|
appTree.write(
|
|
116
|
-
'
|
|
100
|
+
'test-ui-app/src/app/some-utils.js',
|
|
117
101
|
`export const add = (a: number, b: number) => a + b;`
|
|
118
102
|
);
|
|
119
103
|
|
|
@@ -123,14 +107,12 @@ describe('react:stories for applications', () => {
|
|
|
123
107
|
|
|
124
108
|
// should just create the story and not error, even though there's a js file
|
|
125
109
|
// not containing any react component
|
|
126
|
-
expect(
|
|
127
|
-
appTree.exists('apps/test-ui-app/src/app/App.stories.tsx')
|
|
128
|
-
).toBeTruthy();
|
|
110
|
+
expect(appTree.exists('test-ui-app/src/app/App.stories.tsx')).toBeTruthy();
|
|
129
111
|
});
|
|
130
112
|
});
|
|
131
113
|
|
|
132
114
|
export async function createTestUIApp(libName: string): Promise<Tree> {
|
|
133
|
-
let appTree = createTreeWithEmptyWorkspace(
|
|
115
|
+
let appTree = createTreeWithEmptyWorkspace();
|
|
134
116
|
appTree.write('.gitignore', '');
|
|
135
117
|
|
|
136
118
|
await applicationGenerator(appTree, {
|
|
@@ -140,6 +122,7 @@ export async function createTestUIApp(libName: string): Promise<Tree> {
|
|
|
140
122
|
unitTestRunner: 'none',
|
|
141
123
|
name: libName,
|
|
142
124
|
install: false,
|
|
125
|
+
projectNameAndRootFormat: 'as-provided',
|
|
143
126
|
});
|
|
144
127
|
return appTree;
|
|
145
128
|
}
|