@nx/react-native 0.0.0-pr-22179-271588f → 0.0.0-pr-26482-ebe2dba

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.
Files changed (71) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/migrations.json +78 -287
  4. package/package.json +11 -10
  5. package/plugins/plugin.js +17 -38
  6. package/plugins/with-nx-metro.js +3 -2
  7. package/project.json +1 -3
  8. package/src/executors/ensure-symlink/ensure-symlink.impl.d.ts +1 -1
  9. package/src/executors/ensure-symlink/ensure-symlink.impl.js +1 -1
  10. package/src/executors/storybook/schema.d.ts +1 -0
  11. package/src/executors/storybook/storybook.impl.d.ts +1 -1
  12. package/src/executors/storybook/storybook.impl.js +10 -3
  13. package/src/generators/application/files/app/Gemfile.template +4 -2
  14. package/src/generators/application/files/app/android/app/build.gradle.template +0 -1
  15. package/src/generators/application/files/app/android/app/src/main/java/com/__lowerCaseName__/MainApplication.kt.template +1 -3
  16. package/src/generators/application/files/app/android/build.gradle.template +3 -3
  17. package/src/generators/application/files/app/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  18. package/src/generators/application/files/app/android/gradlew.bat +10 -10
  19. package/src/generators/application/files/app/android/gradlew.template +7 -7
  20. package/src/generators/application/files/app/ios/Podfile.template +2 -17
  21. package/src/generators/application/files/app/ios/__className__/AppDelegate.mm.template +2 -2
  22. package/src/generators/application/files/app/ios/__className__/Info.plist.template +1 -1
  23. package/src/generators/application/files/app/ios/__className__/PrivacyInfo.xcprivacy +38 -0
  24. package/src/generators/application/files/app/ios/__className__.xcodeproj/project.pbxproj.template +5 -1
  25. package/src/generators/application/files/app/metro.config.js.template +1 -1
  26. package/src/generators/application/files/app/tsconfig.app.json.template +1 -1
  27. package/src/generators/application/lib/normalize-options.d.ts +3 -0
  28. package/src/generators/application/lib/normalize-options.js +23 -0
  29. package/src/generators/application/schema.json +2 -2
  30. package/src/generators/component/schema.d.ts +1 -1
  31. package/src/generators/component/schema.json +1 -1
  32. package/src/generators/init/init.js +44 -31
  33. package/src/generators/init/lib/gitignore-entries.d.ts +1 -1
  34. package/src/generators/init/lib/gitignore-entries.js +2 -2
  35. package/src/generators/library/files/lib/tsconfig.lib.json.template +1 -1
  36. package/src/generators/web-configuration/files/base-webpack/webpack.config.js__tmpl__ +3 -3
  37. package/src/migrations/update-18-0-0/change-storybook-targets.js +1 -1
  38. package/src/utils/add-jest.js +2 -2
  39. package/src/utils/versions.d.ts +9 -9
  40. package/src/utils/versions.js +9 -9
  41. package/src/executors/build-android/build-android.impl.ts +0 -69
  42. package/src/executors/build-ios/build-ios.impl.ts +0 -77
  43. package/src/executors/bundle/bundle.impl.ts +0 -77
  44. package/src/executors/ensure-symlink/ensure-symlink.impl.ts +0 -22
  45. package/src/executors/pod-install/pod-install.impl.ts +0 -21
  46. package/src/executors/run-android/run-android.impl.ts +0 -94
  47. package/src/executors/run-ios/run-ios.impl.ts +0 -92
  48. package/src/executors/start/start.impl.ts +0 -111
  49. package/src/executors/storybook/storybook.impl.ts +0 -85
  50. package/src/executors/sync-deps/sync-deps.impl.ts +0 -140
  51. package/src/executors/upgrade/upgrade.impl.ts +0 -64
  52. package/src/generators/application/application.spec.ts +0 -258
  53. package/src/generators/application/files/app/test-setup.ts.template +0 -1
  54. package/src/generators/application/lib/normalize-options.spec.ts +0 -196
  55. package/src/generators/component/component.spec.ts +0 -127
  56. package/src/generators/init/init.spec.ts +0 -38
  57. package/src/generators/library/files/lib/test-setup.ts.template +0 -1
  58. package/src/generators/library/library.spec.ts +0 -420
  59. package/src/migrations/update-15-0-0/add-babel-inputs.d.ts +0 -2
  60. package/src/migrations/update-15-0-0/add-babel-inputs.js +0 -9
  61. package/src/migrations/update-15-0-0/add-babel-inputs.spec.ts +0 -73
  62. package/src/migrations/update-15-9-1/add-build-ios-target.d.ts +0 -5
  63. package/src/migrations/update-15-9-1/add-build-ios-target.js +0 -29
  64. package/src/migrations/update-15-9-1/add-build-ios-target.spec.ts +0 -36
  65. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.spec.ts +0 -37
  66. package/src/migrations/update-18-0-0/add-web-configuration.spec.ts +0 -39
  67. package/src/migrations/update-18-0-0/remove-block-list.spec.ts +0 -68
  68. package/src/migrations/update-18-0-0/remove-symlink-target.spec.ts +0 -40
  69. package/src/utils/add-linting.spec.ts +0 -40
  70. package/src/utils/ensure-node-modules-symlink.spec.ts +0 -108
  71. package/src/utils/find-all-npm-dependencies.spec.ts +0 -103
@@ -1,127 +0,0 @@
1
- import { logger, Tree } from '@nx/devkit';
2
- import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
3
- import { createApp, createLib } from '../../utils/testing-generators';
4
- import { reactNativeComponentGenerator } from './component';
5
-
6
- describe('component', () => {
7
- let appTree: Tree;
8
- let projectName: string;
9
-
10
- beforeEach(async () => {
11
- projectName = 'my-lib';
12
- appTree = createTreeWithEmptyWorkspace();
13
- appTree.write('.gitignore', '');
14
- await createApp(appTree, 'my-app');
15
- await createLib(appTree, projectName);
16
- jest.spyOn(logger, 'warn').mockImplementation(() => {});
17
- jest.spyOn(logger, 'debug').mockImplementation(() => {});
18
- });
19
-
20
- afterEach(() => {
21
- jest.restoreAllMocks();
22
- });
23
-
24
- it('should generate component files', async () => {
25
- await reactNativeComponentGenerator(appTree, {
26
- name: 'hello',
27
- project: projectName,
28
- });
29
-
30
- expect(appTree.exists('my-lib/src/lib/hello/hello.tsx')).toBeTruthy();
31
- expect(appTree.exists('my-lib/src/lib/hello/hello.spec.tsx')).toBeTruthy();
32
- });
33
-
34
- it('should generate files for an app', async () => {
35
- await reactNativeComponentGenerator(appTree, {
36
- name: 'hello',
37
- project: 'my-app',
38
- });
39
-
40
- expect(appTree.exists('my-app/src/app/hello/hello.tsx')).toBeTruthy();
41
- expect(appTree.exists('my-app/src/app/hello/hello.spec.tsx')).toBeTruthy();
42
- });
43
-
44
- describe('--export', () => {
45
- it('should add to index.ts barrel', async () => {
46
- await reactNativeComponentGenerator(appTree, {
47
- name: 'hello',
48
- project: projectName,
49
- export: true,
50
- });
51
-
52
- const indexContent = appTree.read('my-lib/src/index.ts', 'utf-8');
53
-
54
- expect(indexContent).toMatch(/lib\/hello/);
55
- });
56
-
57
- it('should not export from an app', async () => {
58
- await reactNativeComponentGenerator(appTree, {
59
- name: 'hello',
60
- project: 'my-app',
61
- export: true,
62
- });
63
-
64
- const indexContent = appTree.read('my-lib/src/index.ts', 'utf-8');
65
-
66
- expect(indexContent).not.toMatch(/lib\/hello/);
67
- });
68
- });
69
-
70
- describe('--pascalCaseFiles', () => {
71
- it('should generate component files with upper case names', async () => {
72
- await reactNativeComponentGenerator(appTree, {
73
- name: 'hello',
74
- project: projectName,
75
- pascalCaseFiles: true,
76
- });
77
- expect(appTree.exists('my-lib/src/lib/hello/Hello.tsx')).toBeTruthy();
78
- expect(
79
- appTree.exists('my-lib/src/lib/hello/Hello.spec.tsx')
80
- ).toBeTruthy();
81
- });
82
- });
83
-
84
- describe('--directory', () => {
85
- it('should create component under the directory', async () => {
86
- await reactNativeComponentGenerator(appTree, {
87
- name: 'hello',
88
- project: projectName,
89
- directory: 'components',
90
- });
91
-
92
- expect(appTree.exists('my-lib/src/components/hello/hello.tsx'));
93
- });
94
-
95
- it('should create with nested directories', async () => {
96
- await reactNativeComponentGenerator(appTree, {
97
- name: 'helloWorld',
98
- project: projectName,
99
- directory: 'lib/foo',
100
- });
101
-
102
- expect(appTree.exists('my-lib/src/lib/foo/hello-world/hello-world.tsx'));
103
- });
104
- });
105
-
106
- describe('--flat', () => {
107
- it('should create in project directory rather than in its own folder', async () => {
108
- await reactNativeComponentGenerator(appTree, {
109
- name: 'hello',
110
- project: projectName,
111
- flat: true,
112
- });
113
-
114
- expect(appTree.exists('my-lib/src/lib/hello.tsx'));
115
- });
116
- it('should work with custom directory path', async () => {
117
- await reactNativeComponentGenerator(appTree, {
118
- name: 'hello',
119
- project: projectName,
120
- flat: true,
121
- directory: 'components',
122
- });
123
-
124
- expect(appTree.exists('my-lib/src/components/hello.tsx'));
125
- });
126
- });
127
- });
@@ -1,38 +0,0 @@
1
- import { Tree, readJson } from '@nx/devkit';
2
- import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
3
- import { reactNativeInitGenerator } from './init';
4
-
5
- describe('init', () => {
6
- let tree: Tree;
7
-
8
- beforeEach(() => {
9
- tree = createTreeWithEmptyWorkspace();
10
- tree.write('.gitignore', '');
11
- });
12
-
13
- it('should add react native dependencies', async () => {
14
- await reactNativeInitGenerator(tree, {
15
- addPlugin: true,
16
- });
17
- const packageJson = readJson(tree, 'package.json');
18
- expect(packageJson.dependencies['react']).toBeDefined();
19
- expect(packageJson.dependencies['react-native']).toBeDefined();
20
- });
21
-
22
- it('should add .gitignore entries for React native files and directories', async () => {
23
- tree.write(
24
- '/.gitignore',
25
- `
26
- /node_modules
27
- `
28
- );
29
- await reactNativeInitGenerator(tree, {
30
- addPlugin: true,
31
- });
32
-
33
- const content = tree.read('/.gitignore').toString();
34
-
35
- expect(content).toMatch(/# React Native/);
36
- expect(content).toMatch(/# Nested node_modules/);
37
- });
38
- });
@@ -1 +0,0 @@
1
- import '@testing-library/jest-native/extend-expect';
@@ -1,420 +0,0 @@
1
- import {
2
- readJson,
3
- readProjectConfiguration,
4
- Tree,
5
- updateJson,
6
- } from '@nx/devkit';
7
- import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
8
- import libraryGenerator from './library';
9
- import { Linter } from '@nx/eslint';
10
- import { Schema } from './schema';
11
-
12
- describe('lib', () => {
13
- let appTree: Tree;
14
-
15
- const defaultSchema: Schema = {
16
- name: 'my-lib',
17
- linter: Linter.EsLint,
18
- skipFormat: false,
19
- skipTsConfig: false,
20
- unitTestRunner: 'jest',
21
- strict: true,
22
- projectNameAndRootFormat: 'as-provided',
23
- addPlugin: true,
24
- };
25
-
26
- beforeEach(() => {
27
- appTree = createTreeWithEmptyWorkspace();
28
- appTree.write('.gitignore', '');
29
- });
30
-
31
- describe('not nested', () => {
32
- it('should update root tsconfig.base.json', async () => {
33
- await libraryGenerator(appTree, defaultSchema);
34
- const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
35
- expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
36
- 'my-lib/src/index.ts',
37
- ]);
38
- });
39
-
40
- it('should update root tsconfig.json when no tsconfig.base.json', async () => {
41
- appTree.rename('tsconfig.base.json', 'tsconfig.json');
42
-
43
- await libraryGenerator(appTree, defaultSchema);
44
-
45
- const tsconfigJson = readJson(appTree, '/tsconfig.json');
46
- expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
47
- 'my-lib/src/index.ts',
48
- ]);
49
- });
50
-
51
- it('should update root tsconfig.base.json (no existing path mappings)', async () => {
52
- updateJson(appTree, 'tsconfig.base.json', (json) => {
53
- json.compilerOptions.paths = undefined;
54
- return json;
55
- });
56
-
57
- await libraryGenerator(appTree, defaultSchema);
58
- const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
59
- expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
60
- 'my-lib/src/index.ts',
61
- ]);
62
- });
63
-
64
- it('should create a local tsconfig.json', async () => {
65
- await libraryGenerator(appTree, defaultSchema);
66
-
67
- const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.json');
68
- expect(tsconfigJson.extends).toBe('../tsconfig.base.json');
69
- expect(tsconfigJson.references).toEqual([
70
- {
71
- path: './tsconfig.lib.json',
72
- },
73
- {
74
- path: './tsconfig.spec.json',
75
- },
76
- ]);
77
- expect(
78
- tsconfigJson.compilerOptions.forceConsistentCasingInFileNames
79
- ).toEqual(true);
80
- expect(tsconfigJson.compilerOptions.strict).toEqual(true);
81
- expect(tsconfigJson.compilerOptions.noImplicitReturns).toEqual(true);
82
- expect(tsconfigJson.compilerOptions.noFallthroughCasesInSwitch).toEqual(
83
- true
84
- );
85
- });
86
-
87
- it('should extend from root tsconfig.json when no tsconfig.base.json', async () => {
88
- appTree.rename('tsconfig.base.json', 'tsconfig.json');
89
-
90
- await libraryGenerator(appTree, defaultSchema);
91
-
92
- const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.json');
93
- expect(tsconfigJson.extends).toBe('../tsconfig.json');
94
- });
95
-
96
- it('should extend the local tsconfig.json with tsconfig.spec.json', async () => {
97
- await libraryGenerator(appTree, defaultSchema);
98
- const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.spec.json');
99
- expect(tsconfigJson.extends).toEqual('./tsconfig.json');
100
- });
101
-
102
- it('should extend the local tsconfig.json with tsconfig.lib.json', async () => {
103
- await libraryGenerator(appTree, defaultSchema);
104
- const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.lib.json');
105
- expect(tsconfigJson.extends).toEqual('./tsconfig.json');
106
- });
107
- });
108
-
109
- describe('nested', () => {
110
- it('should update nx.json', async () => {
111
- await libraryGenerator(appTree, {
112
- ...defaultSchema,
113
- directory: 'my-dir',
114
- tags: 'one',
115
- });
116
-
117
- const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
118
- expect(projectConfiguration).toMatchObject({
119
- tags: ['one'],
120
- });
121
-
122
- await libraryGenerator(appTree, {
123
- ...defaultSchema,
124
- name: 'my-lib2',
125
- directory: 'my-dir2',
126
- tags: 'one,two',
127
- });
128
-
129
- const lib2ProjectConfiguration = readProjectConfiguration(
130
- appTree,
131
- 'my-lib2'
132
- );
133
- expect(lib2ProjectConfiguration).toMatchObject({
134
- tags: ['one', 'two'],
135
- });
136
- });
137
-
138
- it('should update root tsconfig.base.json', async () => {
139
- await libraryGenerator(appTree, {
140
- ...defaultSchema,
141
- directory: 'my-dir',
142
- });
143
- const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
144
- expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
145
- 'my-dir/src/index.ts',
146
- ]);
147
- expect(
148
- tsconfigJson.compilerOptions.paths['my-dir-my-lib/*']
149
- ).toBeUndefined();
150
- });
151
-
152
- it('should update root tsconfig.json when no tsconfig.base.json', async () => {
153
- appTree.rename('tsconfig.base.json', 'tsconfig.json');
154
-
155
- await libraryGenerator(appTree, {
156
- ...defaultSchema,
157
- directory: 'my-dir',
158
- });
159
-
160
- const tsconfigJson = readJson(appTree, '/tsconfig.json');
161
- expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
162
- 'my-dir/src/index.ts',
163
- ]);
164
- expect(
165
- tsconfigJson.compilerOptions.paths['my-dir-my-lib/*']
166
- ).toBeUndefined();
167
- });
168
-
169
- it('should create a local tsconfig.json', async () => {
170
- await libraryGenerator(appTree, {
171
- ...defaultSchema,
172
- directory: 'my-dir',
173
- });
174
-
175
- const tsconfigJson = readJson(appTree, 'my-dir/tsconfig.json');
176
- expect(tsconfigJson.extends).toBe('../tsconfig.base.json');
177
- expect(tsconfigJson.references).toEqual([
178
- {
179
- path: './tsconfig.lib.json',
180
- },
181
- {
182
- path: './tsconfig.spec.json',
183
- },
184
- ]);
185
- });
186
-
187
- it('should extend from root tsconfig.json when no tsconfig.base.json', async () => {
188
- appTree.rename('tsconfig.base.json', 'tsconfig.json');
189
-
190
- await libraryGenerator(appTree, {
191
- ...defaultSchema,
192
- directory: 'my-dir',
193
- });
194
-
195
- const tsconfigJson = readJson(appTree, 'my-dir/tsconfig.json');
196
- expect(tsconfigJson.extends).toBe('../tsconfig.json');
197
- });
198
- });
199
-
200
- describe('--unit-test-runner none', () => {
201
- it('should not generate test configuration', async () => {
202
- await libraryGenerator(appTree, {
203
- ...defaultSchema,
204
- unitTestRunner: 'none',
205
- });
206
-
207
- expect(appTree.exists('my-lib/tsconfig.spec.json')).toBeFalsy();
208
- expect(appTree.exists('my-lib/jest.config.ts')).toBeFalsy();
209
- });
210
-
211
- it('should generate test configuration', async () => {
212
- await libraryGenerator(appTree, {
213
- ...defaultSchema,
214
- unitTestRunner: 'jest',
215
- });
216
-
217
- expect(appTree.read('my-lib/tsconfig.spec.json', 'utf-8'))
218
- .toMatchInlineSnapshot(`
219
- "{
220
- "extends": "./tsconfig.json",
221
- "compilerOptions": {
222
- "outDir": "../dist/out-tsc",
223
- "module": "commonjs",
224
- "types": ["jest", "node"]
225
- },
226
- "include": [
227
- "jest.config.ts",
228
- "src/**/*.test.ts",
229
- "src/**/*.spec.ts",
230
- "src/**/*.test.tsx",
231
- "src/**/*.spec.tsx",
232
- "src/**/*.test.js",
233
- "src/**/*.spec.js",
234
- "src/**/*.test.jsx",
235
- "src/**/*.spec.jsx",
236
- "src/**/*.d.ts"
237
- ]
238
- }
239
- "
240
- `);
241
- expect(appTree.read('my-lib/jest.config.ts', 'utf-8'))
242
- .toMatchInlineSnapshot(`
243
- "module.exports = {
244
- displayName: 'my-lib',
245
- preset: 'react-native',
246
- resolver: '@nx/jest/plugins/resolver',
247
- moduleFileExtensions: ['ts', 'js', 'html', 'tsx', 'jsx'],
248
- setupFilesAfterEnv: ['<rootDir>/test-setup.ts'],
249
- moduleNameMapper: {
250
- '\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock',
251
- },
252
- transform: {
253
- '^.+.(js|ts|tsx)$': [
254
- 'babel-jest',
255
- {
256
- configFile: __dirname + '/.babelrc.js',
257
- },
258
- ],
259
- '^.+.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve(
260
- 'react-native/jest/assetFileTransformer.js'
261
- ),
262
- },
263
- coverageDirectory: '../coverage/my-lib',
264
- };
265
- "
266
- `);
267
- });
268
- });
269
-
270
- describe('--buildable', () => {
271
- it('should have a builder defined', async () => {
272
- await libraryGenerator(appTree, {
273
- ...defaultSchema,
274
- buildable: true,
275
- });
276
-
277
- const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
278
-
279
- expect(projectConfiguration.targets.build).toBeDefined();
280
- });
281
- });
282
-
283
- describe('--publishable', () => {
284
- it('should add build architect', async () => {
285
- await libraryGenerator(appTree, {
286
- ...defaultSchema,
287
- publishable: true,
288
- importPath: '@proj/my-lib',
289
- });
290
-
291
- const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
292
-
293
- expect(projectConfiguration.targets.build).toMatchObject({
294
- executor: '@nx/rollup:rollup',
295
- outputs: ['{options.outputPath}'],
296
- options: {
297
- external: ['react/jsx-runtime', 'react-native', 'react', 'react-dom'],
298
- entryFile: 'my-lib/src/index.ts',
299
- outputPath: 'dist/my-lib',
300
- project: 'my-lib/package.json',
301
- tsConfig: 'my-lib/tsconfig.lib.json',
302
- rollupConfig: '@nx/react/plugins/bundle-rollup',
303
- },
304
- });
305
- });
306
-
307
- it('should fail if no importPath is provided with publishable', async () => {
308
- expect.assertions(1);
309
-
310
- try {
311
- await libraryGenerator(appTree, {
312
- ...defaultSchema,
313
- directory: 'my-dir',
314
- publishable: true,
315
- });
316
- } catch (e) {
317
- expect(e.message).toContain(
318
- '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)'
319
- );
320
- }
321
- });
322
-
323
- it('should add package.json and .babelrc', async () => {
324
- await libraryGenerator(appTree, {
325
- ...defaultSchema,
326
- publishable: true,
327
- importPath: '@proj/my-lib',
328
- });
329
-
330
- const packageJson = readJson(appTree, 'my-lib/package.json');
331
- expect(packageJson.name).toEqual('@proj/my-lib');
332
- expect(appTree.exists('my-lib/.babelrc'));
333
- });
334
- });
335
-
336
- describe('--js', () => {
337
- it('should generate JS files', async () => {
338
- await libraryGenerator(appTree, {
339
- ...defaultSchema,
340
- js: true,
341
- });
342
-
343
- expect(appTree.exists('my-lib/src/index.js')).toBe(true);
344
- });
345
- });
346
-
347
- describe('--importPath', () => {
348
- it('should update the package.json & tsconfig with the given import path', async () => {
349
- await libraryGenerator(appTree, {
350
- ...defaultSchema,
351
- publishable: true,
352
- directory: 'my-dir',
353
- importPath: '@myorg/lib',
354
- });
355
- const packageJson = readJson(appTree, 'my-dir/package.json');
356
- const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
357
-
358
- expect(packageJson.name).toBe('@myorg/lib');
359
- expect(
360
- tsconfigJson.compilerOptions.paths[packageJson.name]
361
- ).toBeDefined();
362
- });
363
-
364
- it('should fail if the same importPath has already been used', async () => {
365
- await libraryGenerator(appTree, {
366
- ...defaultSchema,
367
- name: 'my-lib1',
368
- publishable: true,
369
- importPath: '@myorg/lib',
370
- });
371
-
372
- try {
373
- await libraryGenerator(appTree, {
374
- ...defaultSchema,
375
- name: 'my-lib2',
376
- publishable: true,
377
- importPath: '@myorg/lib',
378
- });
379
- } catch (e) {
380
- expect(e.message).toContain(
381
- 'You already have a library using the import path'
382
- );
383
- }
384
-
385
- expect.assertions(1);
386
- });
387
- });
388
-
389
- describe('--no-strict', () => {
390
- it('should not add options for strict mode', async () => {
391
- await libraryGenerator(appTree, {
392
- ...defaultSchema,
393
- strict: false,
394
- });
395
- const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.json');
396
-
397
- expect(
398
- tsconfigJson.compilerOptions.forceConsistentCasingInFileNames
399
- ).not.toBeDefined();
400
- expect(tsconfigJson.compilerOptions.strict).not.toBeDefined();
401
- expect(tsconfigJson.compilerOptions.noImplicitReturns).not.toBeDefined();
402
- expect(
403
- tsconfigJson.compilerOptions.noFallthroughCasesInSwitch
404
- ).not.toBeDefined();
405
- });
406
- });
407
-
408
- describe('--skipPackageJson', () => {
409
- it('should not add or update dependencies when true', async () => {
410
- const packageJsonBefore = readJson(appTree, 'package.json');
411
-
412
- await libraryGenerator(appTree, {
413
- ...defaultSchema,
414
- skipPackageJson: true,
415
- });
416
-
417
- expect(readJson(appTree, 'package.json')).toEqual(packageJsonBefore);
418
- });
419
- });
420
- });
@@ -1,2 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- export default function (tree: Tree): Promise<void>;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const devkit_1 = require("@nx/devkit");
4
- const add_babel_inputs_1 = require("@nx/js/src/utils/add-babel-inputs");
5
- async function default_1(tree) {
6
- (0, add_babel_inputs_1.addBabelInputs)(tree);
7
- await (0, devkit_1.formatFiles)(tree);
8
- }
9
- exports.default = default_1;
@@ -1,73 +0,0 @@
1
- import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
2
- import { Tree, readNxJson, updateNxJson } from '@nx/devkit';
3
- import addBabelInputs from './add-babel-inputs';
4
-
5
- describe('15.0.0 migration (add-babel-inputs)', () => {
6
- let tree: Tree;
7
-
8
- beforeEach(() => {
9
- tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
10
- });
11
-
12
- it('should add babel.config.json to sharedGlobals', async () => {
13
- updateNxJson(tree, {
14
- namedInputs: {
15
- default: ['{projectRoot}/**/*', 'sharedGlobals'],
16
- sharedGlobals: [],
17
- production: ['default'],
18
- },
19
- });
20
- tree.write('babel.config.json', '');
21
-
22
- await addBabelInputs(tree);
23
-
24
- const updated = readNxJson(tree);
25
- expect(updated).toMatchInlineSnapshot(`
26
- {
27
- "namedInputs": {
28
- "default": [
29
- "{projectRoot}/**/*",
30
- "sharedGlobals",
31
- ],
32
- "production": [
33
- "default",
34
- ],
35
- "sharedGlobals": [
36
- "{workspaceRoot}/babel.config.json",
37
- ],
38
- },
39
- }
40
- `);
41
- });
42
-
43
- it('should add babel.config.js', async () => {
44
- updateNxJson(tree, {
45
- namedInputs: {
46
- default: ['{projectRoot}/**/*', 'sharedGlobals'],
47
- sharedGlobals: [],
48
- production: ['default'],
49
- },
50
- });
51
- tree.write('babel.config.js', '');
52
-
53
- await addBabelInputs(tree);
54
-
55
- const updated = readNxJson(tree);
56
- expect(updated).toMatchInlineSnapshot(`
57
- {
58
- "namedInputs": {
59
- "default": [
60
- "{projectRoot}/**/*",
61
- "sharedGlobals",
62
- ],
63
- "production": [
64
- "default",
65
- ],
66
- "sharedGlobals": [
67
- "{workspaceRoot}/babel.config.js",
68
- ],
69
- },
70
- }
71
- `);
72
- });
73
- });
@@ -1,5 +0,0 @@
1
- import { Tree } from '@nx/devkit';
2
- /**
3
- * Add build-ios target for react-native
4
- */
5
- export default function update(tree: Tree): Promise<void>;