@nx/react-native 19.2.0-canary.20240604-0594deb → 19.2.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/package.json +8 -8
- package/plugins/plugin.js +1 -1
- package/project.json +1 -1
- package/src/executors/build-android/build-android.impl.ts +0 -69
- package/src/executors/build-ios/build-ios.impl.ts +0 -77
- package/src/executors/bundle/bundle.impl.ts +0 -77
- package/src/executors/ensure-symlink/ensure-symlink.impl.ts +0 -22
- package/src/executors/pod-install/pod-install.impl.ts +0 -21
- package/src/executors/run-android/run-android.impl.ts +0 -94
- package/src/executors/run-ios/run-ios.impl.ts +0 -92
- package/src/executors/start/start.impl.ts +0 -111
- package/src/executors/storybook/storybook.impl.ts +0 -93
- package/src/executors/sync-deps/sync-deps.impl.ts +0 -140
- package/src/executors/upgrade/upgrade.impl.ts +0 -64
- package/src/generators/application/application.spec.ts +0 -260
- package/src/generators/application/lib/normalize-options.spec.ts +0 -211
- package/src/generators/component/component.spec.ts +0 -129
- package/src/generators/init/init.spec.ts +0 -40
- package/src/generators/library/library.spec.ts +0 -423
- package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.spec.ts +0 -37
- package/src/migrations/update-18-0-0/add-web-configuration.spec.ts +0 -39
- package/src/migrations/update-18-0-0/remove-block-list.spec.ts +0 -68
- package/src/migrations/update-18-0-0/remove-symlink-target.spec.ts +0 -40
- package/src/utils/add-linting.spec.ts +0 -42
- package/src/utils/ensure-node-modules-symlink.spec.ts +0 -108
- package/src/utils/find-all-npm-dependencies.spec.ts +0 -103
|
@@ -1,423 +0,0 @@
|
|
|
1
|
-
import 'nx/src/internal-testing-utils/mock-project-graph';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
readJson,
|
|
5
|
-
readProjectConfiguration,
|
|
6
|
-
Tree,
|
|
7
|
-
updateJson,
|
|
8
|
-
} from '@nx/devkit';
|
|
9
|
-
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
10
|
-
import libraryGenerator from './library';
|
|
11
|
-
import { Linter } from '@nx/eslint';
|
|
12
|
-
import { Schema } from './schema';
|
|
13
|
-
|
|
14
|
-
describe('lib', () => {
|
|
15
|
-
let appTree: Tree;
|
|
16
|
-
|
|
17
|
-
const defaultSchema: Schema = {
|
|
18
|
-
name: 'my-lib',
|
|
19
|
-
linter: Linter.EsLint,
|
|
20
|
-
skipFormat: false,
|
|
21
|
-
skipTsConfig: false,
|
|
22
|
-
unitTestRunner: 'jest',
|
|
23
|
-
strict: true,
|
|
24
|
-
projectNameAndRootFormat: 'as-provided',
|
|
25
|
-
addPlugin: true,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
appTree = createTreeWithEmptyWorkspace();
|
|
30
|
-
appTree.write('.gitignore', '');
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe('not nested', () => {
|
|
34
|
-
it('should update root tsconfig.base.json', async () => {
|
|
35
|
-
await libraryGenerator(appTree, defaultSchema);
|
|
36
|
-
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
|
37
|
-
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
|
38
|
-
'my-lib/src/index.ts',
|
|
39
|
-
]);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('should update root tsconfig.json when no tsconfig.base.json', async () => {
|
|
43
|
-
appTree.rename('tsconfig.base.json', 'tsconfig.json');
|
|
44
|
-
|
|
45
|
-
await libraryGenerator(appTree, defaultSchema);
|
|
46
|
-
|
|
47
|
-
const tsconfigJson = readJson(appTree, '/tsconfig.json');
|
|
48
|
-
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
|
49
|
-
'my-lib/src/index.ts',
|
|
50
|
-
]);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('should update root tsconfig.base.json (no existing path mappings)', async () => {
|
|
54
|
-
updateJson(appTree, 'tsconfig.base.json', (json) => {
|
|
55
|
-
json.compilerOptions.paths = undefined;
|
|
56
|
-
return json;
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
await libraryGenerator(appTree, defaultSchema);
|
|
60
|
-
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
|
61
|
-
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
|
62
|
-
'my-lib/src/index.ts',
|
|
63
|
-
]);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('should create a local tsconfig.json', async () => {
|
|
67
|
-
await libraryGenerator(appTree, defaultSchema);
|
|
68
|
-
|
|
69
|
-
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.json');
|
|
70
|
-
expect(tsconfigJson.extends).toBe('../tsconfig.base.json');
|
|
71
|
-
expect(tsconfigJson.references).toEqual([
|
|
72
|
-
{
|
|
73
|
-
path: './tsconfig.lib.json',
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
path: './tsconfig.spec.json',
|
|
77
|
-
},
|
|
78
|
-
]);
|
|
79
|
-
expect(
|
|
80
|
-
tsconfigJson.compilerOptions.forceConsistentCasingInFileNames
|
|
81
|
-
).toEqual(true);
|
|
82
|
-
expect(tsconfigJson.compilerOptions.strict).toEqual(true);
|
|
83
|
-
expect(tsconfigJson.compilerOptions.noImplicitReturns).toEqual(true);
|
|
84
|
-
expect(tsconfigJson.compilerOptions.noFallthroughCasesInSwitch).toEqual(
|
|
85
|
-
true
|
|
86
|
-
);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('should extend from root tsconfig.json when no tsconfig.base.json', async () => {
|
|
90
|
-
appTree.rename('tsconfig.base.json', 'tsconfig.json');
|
|
91
|
-
|
|
92
|
-
await libraryGenerator(appTree, defaultSchema);
|
|
93
|
-
|
|
94
|
-
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.json');
|
|
95
|
-
expect(tsconfigJson.extends).toBe('../tsconfig.json');
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('should extend the local tsconfig.json with tsconfig.spec.json', async () => {
|
|
99
|
-
await libraryGenerator(appTree, defaultSchema);
|
|
100
|
-
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.spec.json');
|
|
101
|
-
expect(tsconfigJson.extends).toEqual('./tsconfig.json');
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('should extend the local tsconfig.json with tsconfig.lib.json', async () => {
|
|
105
|
-
await libraryGenerator(appTree, defaultSchema);
|
|
106
|
-
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.lib.json');
|
|
107
|
-
expect(tsconfigJson.extends).toEqual('./tsconfig.json');
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
describe('nested', () => {
|
|
112
|
-
it('should update nx.json', async () => {
|
|
113
|
-
await libraryGenerator(appTree, {
|
|
114
|
-
...defaultSchema,
|
|
115
|
-
directory: 'my-dir',
|
|
116
|
-
tags: 'one',
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
|
120
|
-
expect(projectConfiguration).toMatchObject({
|
|
121
|
-
tags: ['one'],
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
await libraryGenerator(appTree, {
|
|
125
|
-
...defaultSchema,
|
|
126
|
-
name: 'my-lib2',
|
|
127
|
-
directory: 'my-dir2',
|
|
128
|
-
tags: 'one,two',
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
const lib2ProjectConfiguration = readProjectConfiguration(
|
|
132
|
-
appTree,
|
|
133
|
-
'my-lib2'
|
|
134
|
-
);
|
|
135
|
-
expect(lib2ProjectConfiguration).toMatchObject({
|
|
136
|
-
tags: ['one', 'two'],
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it('should update root tsconfig.base.json', async () => {
|
|
141
|
-
await libraryGenerator(appTree, {
|
|
142
|
-
...defaultSchema,
|
|
143
|
-
directory: 'my-dir',
|
|
144
|
-
});
|
|
145
|
-
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
|
146
|
-
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
|
147
|
-
'my-dir/src/index.ts',
|
|
148
|
-
]);
|
|
149
|
-
expect(
|
|
150
|
-
tsconfigJson.compilerOptions.paths['my-dir-my-lib/*']
|
|
151
|
-
).toBeUndefined();
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('should update root tsconfig.json when no tsconfig.base.json', async () => {
|
|
155
|
-
appTree.rename('tsconfig.base.json', 'tsconfig.json');
|
|
156
|
-
|
|
157
|
-
await libraryGenerator(appTree, {
|
|
158
|
-
...defaultSchema,
|
|
159
|
-
directory: 'my-dir',
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
const tsconfigJson = readJson(appTree, '/tsconfig.json');
|
|
163
|
-
expect(tsconfigJson.compilerOptions.paths['@proj/my-lib']).toEqual([
|
|
164
|
-
'my-dir/src/index.ts',
|
|
165
|
-
]);
|
|
166
|
-
expect(
|
|
167
|
-
tsconfigJson.compilerOptions.paths['my-dir-my-lib/*']
|
|
168
|
-
).toBeUndefined();
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it('should create a local tsconfig.json', async () => {
|
|
172
|
-
await libraryGenerator(appTree, {
|
|
173
|
-
...defaultSchema,
|
|
174
|
-
directory: 'my-dir',
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
const tsconfigJson = readJson(appTree, 'my-dir/tsconfig.json');
|
|
178
|
-
expect(tsconfigJson.extends).toBe('../tsconfig.base.json');
|
|
179
|
-
expect(tsconfigJson.references).toEqual([
|
|
180
|
-
{
|
|
181
|
-
path: './tsconfig.lib.json',
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
path: './tsconfig.spec.json',
|
|
185
|
-
},
|
|
186
|
-
]);
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('should extend from root tsconfig.json when no tsconfig.base.json', async () => {
|
|
190
|
-
appTree.rename('tsconfig.base.json', 'tsconfig.json');
|
|
191
|
-
|
|
192
|
-
await libraryGenerator(appTree, {
|
|
193
|
-
...defaultSchema,
|
|
194
|
-
directory: 'my-dir',
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
const tsconfigJson = readJson(appTree, 'my-dir/tsconfig.json');
|
|
198
|
-
expect(tsconfigJson.extends).toBe('../tsconfig.json');
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
describe('--unit-test-runner', () => {
|
|
203
|
-
it('should not generate test configuration', async () => {
|
|
204
|
-
await libraryGenerator(appTree, {
|
|
205
|
-
...defaultSchema,
|
|
206
|
-
unitTestRunner: 'none',
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
expect(appTree.exists('my-lib/tsconfig.spec.json')).toBeFalsy();
|
|
210
|
-
expect(appTree.exists('my-lib/jest.config.ts')).toBeFalsy();
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('should generate test configuration', async () => {
|
|
214
|
-
await libraryGenerator(appTree, {
|
|
215
|
-
...defaultSchema,
|
|
216
|
-
unitTestRunner: 'jest',
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
expect(appTree.read('my-lib/tsconfig.spec.json', 'utf-8'))
|
|
220
|
-
.toMatchInlineSnapshot(`
|
|
221
|
-
"{
|
|
222
|
-
"extends": "./tsconfig.json",
|
|
223
|
-
"compilerOptions": {
|
|
224
|
-
"outDir": "../dist/out-tsc",
|
|
225
|
-
"module": "commonjs",
|
|
226
|
-
"types": ["jest", "node"]
|
|
227
|
-
},
|
|
228
|
-
"files": ["src/test-setup.ts"],
|
|
229
|
-
"include": [
|
|
230
|
-
"jest.config.ts",
|
|
231
|
-
"src/**/*.test.ts",
|
|
232
|
-
"src/**/*.spec.ts",
|
|
233
|
-
"src/**/*.test.tsx",
|
|
234
|
-
"src/**/*.spec.tsx",
|
|
235
|
-
"src/**/*.test.js",
|
|
236
|
-
"src/**/*.spec.js",
|
|
237
|
-
"src/**/*.test.jsx",
|
|
238
|
-
"src/**/*.spec.jsx",
|
|
239
|
-
"src/**/*.d.ts"
|
|
240
|
-
]
|
|
241
|
-
}
|
|
242
|
-
"
|
|
243
|
-
`);
|
|
244
|
-
expect(appTree.read('my-lib/jest.config.ts', 'utf-8'))
|
|
245
|
-
.toMatchInlineSnapshot(`
|
|
246
|
-
"module.exports = {
|
|
247
|
-
displayName: 'my-lib',
|
|
248
|
-
preset: 'react-native',
|
|
249
|
-
resolver: '@nx/jest/plugins/resolver',
|
|
250
|
-
moduleFileExtensions: ['ts', 'js', 'html', 'tsx', 'jsx'],
|
|
251
|
-
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
|
|
252
|
-
moduleNameMapper: {
|
|
253
|
-
'\\\\.svg$': '@nx/react-native/plugins/jest/svg-mock',
|
|
254
|
-
},
|
|
255
|
-
transform: {
|
|
256
|
-
'^.+.(js|ts|tsx)$': [
|
|
257
|
-
'babel-jest',
|
|
258
|
-
{
|
|
259
|
-
configFile: __dirname + '/.babelrc.js',
|
|
260
|
-
},
|
|
261
|
-
],
|
|
262
|
-
'^.+.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': require.resolve(
|
|
263
|
-
'react-native/jest/assetFileTransformer.js'
|
|
264
|
-
),
|
|
265
|
-
},
|
|
266
|
-
coverageDirectory: '../coverage/my-lib',
|
|
267
|
-
};
|
|
268
|
-
"
|
|
269
|
-
`);
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
describe('--buildable', () => {
|
|
274
|
-
it('should have a builder defined', async () => {
|
|
275
|
-
await libraryGenerator(appTree, {
|
|
276
|
-
...defaultSchema,
|
|
277
|
-
buildable: true,
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
|
281
|
-
|
|
282
|
-
expect(projectConfiguration.targets.build).toBeDefined();
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
describe('--publishable', () => {
|
|
287
|
-
it('should add build architect', async () => {
|
|
288
|
-
await libraryGenerator(appTree, {
|
|
289
|
-
...defaultSchema,
|
|
290
|
-
publishable: true,
|
|
291
|
-
importPath: '@proj/my-lib',
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
const projectConfiguration = readProjectConfiguration(appTree, 'my-lib');
|
|
295
|
-
|
|
296
|
-
expect(projectConfiguration.targets.build).toMatchObject({
|
|
297
|
-
executor: '@nx/rollup:rollup',
|
|
298
|
-
outputs: ['{options.outputPath}'],
|
|
299
|
-
options: {
|
|
300
|
-
external: ['react/jsx-runtime', 'react-native', 'react', 'react-dom'],
|
|
301
|
-
entryFile: 'my-lib/src/index.ts',
|
|
302
|
-
outputPath: 'dist/my-lib',
|
|
303
|
-
project: 'my-lib/package.json',
|
|
304
|
-
tsConfig: 'my-lib/tsconfig.lib.json',
|
|
305
|
-
rollupConfig: '@nx/react/plugins/bundle-rollup',
|
|
306
|
-
},
|
|
307
|
-
});
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
it('should fail if no importPath is provided with publishable', async () => {
|
|
311
|
-
expect.assertions(1);
|
|
312
|
-
|
|
313
|
-
try {
|
|
314
|
-
await libraryGenerator(appTree, {
|
|
315
|
-
...defaultSchema,
|
|
316
|
-
directory: 'my-dir',
|
|
317
|
-
publishable: true,
|
|
318
|
-
});
|
|
319
|
-
} catch (e) {
|
|
320
|
-
expect(e.message).toContain(
|
|
321
|
-
'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)'
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
it('should add package.json and .babelrc', async () => {
|
|
327
|
-
await libraryGenerator(appTree, {
|
|
328
|
-
...defaultSchema,
|
|
329
|
-
publishable: true,
|
|
330
|
-
importPath: '@proj/my-lib',
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
const packageJson = readJson(appTree, 'my-lib/package.json');
|
|
334
|
-
expect(packageJson.name).toEqual('@proj/my-lib');
|
|
335
|
-
expect(appTree.exists('my-lib/.babelrc'));
|
|
336
|
-
});
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
describe('--js', () => {
|
|
340
|
-
it('should generate JS files', async () => {
|
|
341
|
-
await libraryGenerator(appTree, {
|
|
342
|
-
...defaultSchema,
|
|
343
|
-
js: true,
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
expect(appTree.exists('my-lib/src/index.js')).toBe(true);
|
|
347
|
-
});
|
|
348
|
-
});
|
|
349
|
-
|
|
350
|
-
describe('--importPath', () => {
|
|
351
|
-
it('should update the package.json & tsconfig with the given import path', async () => {
|
|
352
|
-
await libraryGenerator(appTree, {
|
|
353
|
-
...defaultSchema,
|
|
354
|
-
publishable: true,
|
|
355
|
-
directory: 'my-dir',
|
|
356
|
-
importPath: '@myorg/lib',
|
|
357
|
-
});
|
|
358
|
-
const packageJson = readJson(appTree, 'my-dir/package.json');
|
|
359
|
-
const tsconfigJson = readJson(appTree, '/tsconfig.base.json');
|
|
360
|
-
|
|
361
|
-
expect(packageJson.name).toBe('@myorg/lib');
|
|
362
|
-
expect(
|
|
363
|
-
tsconfigJson.compilerOptions.paths[packageJson.name]
|
|
364
|
-
).toBeDefined();
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
it('should fail if the same importPath has already been used', async () => {
|
|
368
|
-
await libraryGenerator(appTree, {
|
|
369
|
-
...defaultSchema,
|
|
370
|
-
name: 'my-lib1',
|
|
371
|
-
publishable: true,
|
|
372
|
-
importPath: '@myorg/lib',
|
|
373
|
-
});
|
|
374
|
-
|
|
375
|
-
try {
|
|
376
|
-
await libraryGenerator(appTree, {
|
|
377
|
-
...defaultSchema,
|
|
378
|
-
name: 'my-lib2',
|
|
379
|
-
publishable: true,
|
|
380
|
-
importPath: '@myorg/lib',
|
|
381
|
-
});
|
|
382
|
-
} catch (e) {
|
|
383
|
-
expect(e.message).toContain(
|
|
384
|
-
'You already have a library using the import path'
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
expect.assertions(1);
|
|
389
|
-
});
|
|
390
|
-
});
|
|
391
|
-
|
|
392
|
-
describe('--no-strict', () => {
|
|
393
|
-
it('should not add options for strict mode', async () => {
|
|
394
|
-
await libraryGenerator(appTree, {
|
|
395
|
-
...defaultSchema,
|
|
396
|
-
strict: false,
|
|
397
|
-
});
|
|
398
|
-
const tsconfigJson = readJson(appTree, 'my-lib/tsconfig.json');
|
|
399
|
-
|
|
400
|
-
expect(
|
|
401
|
-
tsconfigJson.compilerOptions.forceConsistentCasingInFileNames
|
|
402
|
-
).not.toBeDefined();
|
|
403
|
-
expect(tsconfigJson.compilerOptions.strict).not.toBeDefined();
|
|
404
|
-
expect(tsconfigJson.compilerOptions.noImplicitReturns).not.toBeDefined();
|
|
405
|
-
expect(
|
|
406
|
-
tsconfigJson.compilerOptions.noFallthroughCasesInSwitch
|
|
407
|
-
).not.toBeDefined();
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
describe('--skipPackageJson', () => {
|
|
412
|
-
it('should not add or update dependencies when true', async () => {
|
|
413
|
-
const packageJsonBefore = readJson(appTree, 'package.json');
|
|
414
|
-
|
|
415
|
-
await libraryGenerator(appTree, {
|
|
416
|
-
...defaultSchema,
|
|
417
|
-
skipPackageJson: true,
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
expect(readJson(appTree, 'package.json')).toEqual(packageJsonBefore);
|
|
421
|
-
});
|
|
422
|
-
});
|
|
423
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Tree, readJson, updateJson } from '@nx/devkit';
|
|
2
|
-
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
3
|
-
import replacePackage from './update-16-0-0-add-nx-packages';
|
|
4
|
-
|
|
5
|
-
describe('update-16-0-0-add-nx-packages', () => {
|
|
6
|
-
let tree: Tree;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
tree = createTreeWithEmptyWorkspace();
|
|
9
|
-
|
|
10
|
-
updateJson(tree, 'package.json', (json) => {
|
|
11
|
-
json.devDependencies['@nrwl/react-native'] = '16.0.0';
|
|
12
|
-
return json;
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('should remove the dependency on @nrwl/react-native', async () => {
|
|
17
|
-
await replacePackage(tree);
|
|
18
|
-
|
|
19
|
-
expect(
|
|
20
|
-
readJson(tree, 'package.json').dependencies['@nrwl/react-native']
|
|
21
|
-
).not.toBeDefined();
|
|
22
|
-
expect(
|
|
23
|
-
readJson(tree, 'package.json').devDependencies['@nrwl/react-native']
|
|
24
|
-
).not.toBeDefined();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('should add a dependency on @nx/react-native', async () => {
|
|
28
|
-
await replacePackage(tree);
|
|
29
|
-
|
|
30
|
-
const packageJson = readJson(tree, 'package.json');
|
|
31
|
-
const newDependencyVersion =
|
|
32
|
-
packageJson.devDependencies['@nx/react-native'] ??
|
|
33
|
-
packageJson.dependencies['@nx/react-native'];
|
|
34
|
-
|
|
35
|
-
expect(newDependencyVersion).toBeDefined();
|
|
36
|
-
});
|
|
37
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { addProjectConfiguration, getProjects, Tree } from '@nx/devkit';
|
|
2
|
-
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
3
|
-
import update from './add-web-configuration';
|
|
4
|
-
|
|
5
|
-
describe('add-web-configuration', () => {
|
|
6
|
-
let tree: Tree;
|
|
7
|
-
|
|
8
|
-
beforeEach(async () => {
|
|
9
|
-
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
10
|
-
addProjectConfiguration(tree, 'product', {
|
|
11
|
-
root: 'apps/product',
|
|
12
|
-
sourceRoot: 'apps/product/src',
|
|
13
|
-
targets: {
|
|
14
|
-
start: {
|
|
15
|
-
executor: '@nx/react-native:start',
|
|
16
|
-
options: {},
|
|
17
|
-
},
|
|
18
|
-
serve: {
|
|
19
|
-
executor: 'nx:run-commands',
|
|
20
|
-
options: {
|
|
21
|
-
command: 'nx start product',
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it(`should add web configuration`, async () => {
|
|
29
|
-
await update(tree);
|
|
30
|
-
|
|
31
|
-
tree.exists('apps/product/webpack.config.js');
|
|
32
|
-
getProjects(tree).forEach((project) => {
|
|
33
|
-
expect(project.targets['build'].executor).toEqual('@nx/webpack:webpack');
|
|
34
|
-
expect(project.targets['serve'].executor).toEqual(
|
|
35
|
-
'@nx/webpack:dev-server'
|
|
36
|
-
);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
2
|
-
import { Tree, addProjectConfiguration } from '@nx/devkit';
|
|
3
|
-
import update from './remove-block-list';
|
|
4
|
-
|
|
5
|
-
describe('remove-block-list', () => {
|
|
6
|
-
let tree: Tree;
|
|
7
|
-
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
10
|
-
addProjectConfiguration(tree, 'product', {
|
|
11
|
-
root: 'apps/product',
|
|
12
|
-
targets: {
|
|
13
|
-
start: {
|
|
14
|
-
executor: '@nx/react-native:start',
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
tree.write(
|
|
19
|
-
'apps/product/metro.config.js',
|
|
20
|
-
`
|
|
21
|
-
const { withNxMetro } = require('@nx/expo');
|
|
22
|
-
const { getDefaultConfig } = require('@expo/metro-config');
|
|
23
|
-
const { mergeConfig } = require('metro-config');
|
|
24
|
-
const exclusionList = require('metro-config/src/defaults/exclusionList');
|
|
25
|
-
|
|
26
|
-
const defaultConfig = getDefaultConfig(__dirname);
|
|
27
|
-
const { assetExts, sourceExts } = defaultConfig.resolver;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Metro configuration
|
|
31
|
-
* https://facebook.github.io/metro/docs/configuration
|
|
32
|
-
*
|
|
33
|
-
* @type {import('metro-config').MetroConfig}
|
|
34
|
-
*/
|
|
35
|
-
const customConfig = {
|
|
36
|
-
transformer: {
|
|
37
|
-
babelTransformerPath: require.resolve('react-native-svg-transformer'),
|
|
38
|
-
},
|
|
39
|
-
resolver: {
|
|
40
|
-
assetExts: assetExts.filter((ext) => ext !== 'svg'),
|
|
41
|
-
sourceExts: [...sourceExts, 'svg'],
|
|
42
|
-
blockList: exclusionList([/^(?!.*node_modules).*\/dist\/.*/]),
|
|
43
|
-
unstable_enableSymlinks: true,
|
|
44
|
-
unstable_enablePackageExports: true,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
module.exports = withNxMetro(mergeConfig(defaultConfig, customConfig), {
|
|
50
|
-
// Change this to true to see debugging info.
|
|
51
|
-
// Useful if you have issues resolving modules
|
|
52
|
-
debug: false,
|
|
53
|
-
// all the file extensions used for imports other than 'ts', 'tsx', 'js', 'jsx', 'json'
|
|
54
|
-
extensions: [],
|
|
55
|
-
// Specify folders to watch, in addition to Nx defaults (workspace libraries and node_modules)
|
|
56
|
-
watchFolders: [],
|
|
57
|
-
});`
|
|
58
|
-
);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('should remove blockList', async () => {
|
|
62
|
-
await update(tree);
|
|
63
|
-
const metroConfig = tree.read(`apps/product/metro.config.js`).toString();
|
|
64
|
-
expect(metroConfig).not.toContain('blockList');
|
|
65
|
-
expect(metroConfig).not.toContain('unstable_enableSymlinks');
|
|
66
|
-
expect(metroConfig).not.toContain('unstable_enablePackageExports');
|
|
67
|
-
});
|
|
68
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { addProjectConfiguration, getProjects, Tree } from '@nx/devkit';
|
|
2
|
-
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
3
|
-
import update from './remove-symlink-target';
|
|
4
|
-
|
|
5
|
-
describe('remove-symlink-target', () => {
|
|
6
|
-
let tree: Tree;
|
|
7
|
-
|
|
8
|
-
beforeEach(async () => {
|
|
9
|
-
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
10
|
-
addProjectConfiguration(tree, 'product', {
|
|
11
|
-
root: 'apps/product',
|
|
12
|
-
sourceRoot: 'apps/product/src',
|
|
13
|
-
targets: {
|
|
14
|
-
'ensure-symlink': {
|
|
15
|
-
executor: '@nx/react-native:ensure-symlink',
|
|
16
|
-
options: {},
|
|
17
|
-
},
|
|
18
|
-
'bundle-android': {
|
|
19
|
-
executor: '@nx/react-native:bundle',
|
|
20
|
-
dependsOn: ['ensure-symlink'],
|
|
21
|
-
outputs: ['{options.bundleOutput}'],
|
|
22
|
-
options: {
|
|
23
|
-
entryFile: 'src/main.tsx',
|
|
24
|
-
platform: 'android',
|
|
25
|
-
bundleOutput: 'dist/apps/techy-jokes/android/main.jsbundle',
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it(`should remove ensure-symlink target from project.json`, async () => {
|
|
33
|
-
await update(tree);
|
|
34
|
-
|
|
35
|
-
getProjects(tree).forEach((project) => {
|
|
36
|
-
expect(project.targets['ensure-symlink']).toBeUndefined();
|
|
37
|
-
expect(project.targets['bundle-android'].dependsOn).toEqual([]);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import 'nx/src/internal-testing-utils/mock-project-graph';
|
|
2
|
-
|
|
3
|
-
import { readProjectConfiguration, Tree } from '@nx/devkit';
|
|
4
|
-
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
|
|
5
|
-
import { Linter } from '@nx/eslint';
|
|
6
|
-
import { libraryGenerator } from '@nx/js';
|
|
7
|
-
import { addLinting } from './add-linting';
|
|
8
|
-
|
|
9
|
-
describe('Add Linting', () => {
|
|
10
|
-
let tree: Tree;
|
|
11
|
-
|
|
12
|
-
beforeEach(async () => {
|
|
13
|
-
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
|
14
|
-
await libraryGenerator(tree, {
|
|
15
|
-
name: 'my-lib',
|
|
16
|
-
linter: Linter.None,
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should add a .eslintrc.json when is passed', async () => {
|
|
21
|
-
await addLinting(tree, {
|
|
22
|
-
projectName: 'my-lib',
|
|
23
|
-
linter: Linter.EsLint,
|
|
24
|
-
tsConfigPaths: ['libs/my-lib/tsconfig.lib.json'],
|
|
25
|
-
projectRoot: 'libs/my-lib',
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
expect(tree.exists('libs/my-lib/.eslintrc.json')).toBeTruthy();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('should not add lint target when "none" is passed', async () => {
|
|
32
|
-
await addLinting(tree, {
|
|
33
|
-
projectName: 'my-lib',
|
|
34
|
-
linter: Linter.None,
|
|
35
|
-
tsConfigPaths: ['libs/my-lib/tsconfig.lib.json'],
|
|
36
|
-
projectRoot: 'libs/my-lib',
|
|
37
|
-
});
|
|
38
|
-
const project = readProjectConfiguration(tree, 'my-lib');
|
|
39
|
-
|
|
40
|
-
expect(project.targets.lint).toBeUndefined();
|
|
41
|
-
});
|
|
42
|
-
});
|