react-native-builder-bob 0.40.18 → 0.42.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/bin/bob +1 -1
- package/lib/package.json +93 -0
- package/lib/src/__tests__/babel.test.d.ts +1 -0
- package/lib/src/__tests__/babel.test.js +26 -0
- package/lib/src/__tests__/babel.test.js.map +1 -0
- package/lib/src/__tests__/init.test.d.ts +1 -0
- package/lib/src/__tests__/init.test.js +93 -0
- package/lib/src/__tests__/init.test.js.map +1 -0
- package/lib/src/__tests__/resolveModuleSpecifier.test.d.ts +1 -0
- package/lib/src/__tests__/resolveModuleSpecifier.test.js +95 -0
- package/lib/src/__tests__/resolveModuleSpecifier.test.js.map +1 -0
- package/lib/src/__tests__/typescript-declarations.test.d.ts +1 -0
- package/lib/src/__tests__/typescript-declarations.test.js +193 -0
- package/lib/src/__tests__/typescript-declarations.test.js.map +1 -0
- package/lib/src/__tests__/typescript.test.d.ts +1 -0
- package/lib/src/__tests__/typescript.test.js +243 -0
- package/lib/src/__tests__/typescript.test.js.map +1 -0
- package/lib/src/__tests__/updateSourceMap.test.d.ts +1 -0
- package/lib/src/__tests__/updateSourceMap.test.js +84 -0
- package/lib/src/__tests__/updateSourceMap.test.js.map +1 -0
- package/lib/src/babel.d.ts +19 -0
- package/lib/src/babel.js +58 -0
- package/lib/src/babel.js.map +1 -0
- package/lib/src/build.d.ts +14 -0
- package/lib/src/build.js +122 -0
- package/lib/src/build.js.map +1 -0
- package/lib/src/configs/babel-config.cjs +46 -0
- package/lib/src/configs/babel-config.cjs.map +1 -0
- package/lib/src/configs/babel-config.d.cts +15 -0
- package/lib/src/configs/babel-preset.cjs +66 -0
- package/lib/src/configs/babel-preset.cjs.map +1 -0
- package/lib/src/configs/babel-preset.d.cts +19 -0
- package/lib/src/configs/metro-config.d.mts +4 -0
- package/{metro-config.js → lib/src/configs/metro-config.mjs} +3 -7
- package/lib/src/configs/metro-config.mjs.map +1 -0
- package/lib/src/configs/vite-config.d.mts +2 -0
- package/lib/src/configs/vite-config.mjs +59 -0
- package/lib/src/configs/vite-config.mjs.map +1 -0
- package/lib/src/index.d.ts +1 -0
- package/lib/src/index.js +18 -0
- package/lib/src/index.js.map +1 -0
- package/lib/src/init.d.ts +1 -0
- package/lib/src/init.js +370 -0
- package/lib/src/init.js.map +1 -0
- package/lib/src/schema.d.ts +70 -0
- package/lib/src/schema.js +45 -0
- package/lib/src/schema.js.map +1 -0
- package/lib/src/targets/codegen/index.d.ts +4 -0
- package/lib/src/targets/codegen/index.js +54 -0
- package/lib/src/targets/codegen/index.js.map +1 -0
- package/lib/src/targets/codegen/patches/patchCodegenAndroidPackage.d.ts +11 -0
- package/lib/src/targets/codegen/patches/patchCodegenAndroidPackage.js +63 -0
- package/lib/src/targets/codegen/patches/patchCodegenAndroidPackage.js.map +1 -0
- package/lib/src/targets/codegen/patches/patchCodegenAndroidPackage.test.d.ts +1 -0
- package/lib/src/targets/codegen/patches/patchCodegenAndroidPackage.test.js +103 -0
- package/lib/src/targets/codegen/patches/patchCodegenAndroidPackage.test.js.map +1 -0
- package/lib/src/targets/codegen/patches/removeCodegenAppLevelCode.d.ts +16 -0
- package/lib/src/targets/codegen/patches/removeCodegenAppLevelCode.js +59 -0
- package/lib/src/targets/codegen/patches/removeCodegenAppLevelCode.js.map +1 -0
- package/lib/src/targets/codegen/patches/removeCodegenAppLevelCode.test.d.ts +1 -0
- package/lib/src/targets/codegen/patches/removeCodegenAppLevelCode.test.js +75 -0
- package/lib/src/targets/codegen/patches/removeCodegenAppLevelCode.test.js.map +1 -0
- package/lib/src/targets/commonjs.d.ts +9 -0
- package/lib/src/targets/commonjs.js +19 -0
- package/lib/src/targets/commonjs.js.map +1 -0
- package/lib/src/targets/custom.d.ts +9 -0
- package/lib/src/targets/custom.js +30 -0
- package/lib/src/targets/custom.js.map +1 -0
- package/lib/src/targets/module.d.ts +9 -0
- package/lib/src/targets/module.js +19 -0
- package/lib/src/targets/module.js.map +1 -0
- package/lib/src/targets/typescript.d.ts +12 -0
- package/lib/src/targets/typescript.js +387 -0
- package/lib/src/targets/typescript.js.map +1 -0
- package/lib/src/types.d.ts +24 -0
- package/lib/src/types.js +2 -0
- package/lib/src/types.js.map +1 -0
- package/lib/src/utils/androidAssemble.d.ts +8 -0
- package/lib/src/utils/androidAssemble.js +17 -0
- package/lib/src/utils/androidAssemble.js.map +1 -0
- package/lib/src/utils/compile.d.ts +16 -0
- package/lib/src/utils/compile.js +211 -0
- package/lib/src/utils/compile.js.map +1 -0
- package/lib/src/utils/isCodegenSpec.d.ts +1 -0
- package/lib/src/utils/isCodegenSpec.js +14 -0
- package/lib/src/utils/isCodegenSpec.js.map +1 -0
- package/lib/src/utils/isGitDirty.d.ts +1 -0
- package/lib/src/utils/isGitDirty.js +14 -0
- package/lib/src/utils/isGitDirty.js.map +1 -0
- package/lib/src/utils/loadConfig.d.ts +4 -0
- package/lib/src/utils/loadConfig.js +59 -0
- package/lib/src/utils/loadConfig.js.map +1 -0
- package/lib/src/utils/logger.d.ts +10 -0
- package/lib/src/utils/logger.js +30 -0
- package/lib/src/utils/logger.js.map +1 -0
- package/lib/src/utils/prompts.d.ts +3 -0
- package/lib/src/utils/prompts.js +10 -0
- package/lib/src/utils/prompts.js.map +1 -0
- package/lib/src/utils/resolveModuleSpecifier.d.ts +21 -0
- package/lib/src/utils/resolveModuleSpecifier.js +57 -0
- package/lib/src/utils/resolveModuleSpecifier.js.map +1 -0
- package/lib/src/utils/spawn.d.ts +2 -0
- package/lib/src/utils/spawn.js +41 -0
- package/lib/src/utils/spawn.js.map +1 -0
- package/lib/src/utils/updateSourceMap.d.ts +11 -0
- package/lib/src/utils/updateSourceMap.js +56 -0
- package/lib/src/utils/updateSourceMap.js.map +1 -0
- package/lib/src/utils/workerize.d.ts +15 -0
- package/lib/src/utils/workerize.js +75 -0
- package/lib/src/utils/workerize.js.map +1 -0
- package/package.json +49 -42
- package/babel-config.js +0 -55
- package/babel-preset.js +0 -71
- package/lib/__fixtures__/project/MyNativeComponent.js +0 -8
- package/lib/__fixtures__/project/MyNativeComponent.js.map +0 -1
- package/lib/__fixtures__/project/NativeMyLib.js +0 -2
- package/lib/__fixtures__/project/NativeMyLib.js.map +0 -1
- package/lib/__fixtures__/project/code/$exports-input.js +0 -122
- package/lib/__fixtures__/project/code/$exports-input.js.map +0 -1
- package/lib/__fixtures__/project/code/$exports-output.js +0 -122
- package/lib/__fixtures__/project/code/$exports-output.js.map +0 -1
- package/lib/__fixtures__/project/code/$imports-input.js +0 -24
- package/lib/__fixtures__/project/code/$imports-input.js.map +0 -1
- package/lib/__fixtures__/project/code/$imports-output.js +0 -20
- package/lib/__fixtures__/project/code/$imports-output.js.map +0 -1
- package/lib/__fixtures__/project/code/MyNativeComponent.js +0 -8
- package/lib/__fixtures__/project/code/MyNativeComponent.js.map +0 -1
- package/lib/__fixtures__/project/code/NativeMyLib.js +0 -2
- package/lib/__fixtures__/project/code/NativeMyLib.js.map +0 -1
- package/lib/__fixtures__/project/code/a.js +0 -2
- package/lib/__fixtures__/project/code/a.js.map +0 -1
- package/lib/__fixtures__/project/code/b.js +0 -2
- package/lib/__fixtures__/project/code/b.js.map +0 -1
- package/lib/__fixtures__/project/code/e.story.js +0 -2
- package/lib/__fixtures__/project/code/e.story.js.map +0 -1
- package/lib/__fixtures__/project/f.js +0 -2
- package/lib/__fixtures__/project/f.js.map +0 -1
- package/lib/__fixtures__/project/index.js +0 -2
- package/lib/__fixtures__/project/index.js.map +0 -1
- package/lib/__tests__/babel.test.js +0 -28
- package/lib/__tests__/babel.test.js.map +0 -1
- package/lib/__tests__/init.test.js +0 -93
- package/lib/__tests__/init.test.js.map +0 -1
- package/lib/babel.js +0 -92
- package/lib/babel.js.map +0 -1
- package/lib/build.js +0 -142
- package/lib/build.js.map +0 -1
- package/lib/index.js +0 -16
- package/lib/index.js.map +0 -1
- package/lib/init.js +0 -371
- package/lib/init.js.map +0 -1
- package/lib/schema.js +0 -49
- package/lib/schema.js.map +0 -1
- package/lib/targets/codegen/index.js +0 -60
- package/lib/targets/codegen/index.js.map +0 -1
- package/lib/targets/codegen/patches/patchCodegenAndroidPackage.js +0 -74
- package/lib/targets/codegen/patches/patchCodegenAndroidPackage.js.map +0 -1
- package/lib/targets/codegen/patches/patchCodegenAndroidPackage.test.js +0 -106
- package/lib/targets/codegen/patches/patchCodegenAndroidPackage.test.js.map +0 -1
- package/lib/targets/codegen/patches/removeCodegenAppLevelCode.js +0 -57
- package/lib/targets/codegen/patches/removeCodegenAppLevelCode.js.map +0 -1
- package/lib/targets/codegen/patches/removeCodegenAppLevelCode.test.js +0 -78
- package/lib/targets/codegen/patches/removeCodegenAppLevelCode.test.js.map +0 -1
- package/lib/targets/commonjs.js +0 -34
- package/lib/targets/commonjs.js.map +0 -1
- package/lib/targets/custom.js +0 -40
- package/lib/targets/custom.js.map +0 -1
- package/lib/targets/module.js +0 -34
- package/lib/targets/module.js.map +0 -1
- package/lib/targets/typescript.js +0 -219
- package/lib/targets/typescript.js.map +0 -1
- package/lib/types.js +0 -6
- package/lib/types.js.map +0 -1
- package/lib/utils/androidAssemble.js +0 -29
- package/lib/utils/androidAssemble.js.map +0 -1
- package/lib/utils/compile.js +0 -218
- package/lib/utils/compile.js.map +0 -1
- package/lib/utils/isCodegenSpec.js +0 -22
- package/lib/utils/isCodegenSpec.js.map +0 -1
- package/lib/utils/loadConfig.js +0 -56
- package/lib/utils/loadConfig.js.map +0 -1
- package/lib/utils/logger.js +0 -35
- package/lib/utils/logger.js.map +0 -1
- package/lib/utils/prompts.js +0 -17
- package/lib/utils/prompts.js.map +0 -1
- package/lib/utils/spawn.js +0 -48
- package/lib/utils/spawn.js.map +0 -1
- package/lib/utils/workerize.js +0 -102
- package/lib/utils/workerize.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"patchCodegenAndroidPackage.js","names":["_fsExtra","_interopRequireDefault","require","_path","_kleur","e","__esModule","default","CODEGEN_DOCS","exports","patchCodegenAndroidPackage","projectPath","packageJson","report","codegenAndroidPath","codegenConfig","outputDir","android","Error","path","resolve","fs","pathExists","codegenJavaPackageName","javaPackageName","codegenJavaPath","info","kleur","blue","relative","javaFiles","readdir","Promise","all","map","file","filePath","fileContent","readFile","newFileContent","replace","writeFile","newPackagePath","sep","mkdir","recursive","newFilePath","rename","rm"],"sources":["../../../../src/targets/codegen/patches/patchCodegenAndroidPackage.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport path from 'path';\nimport type { Report } from '../../../types';\nimport kleur from 'kleur';\n\nexport const CODEGEN_DOCS =\n 'https://reactnative.dev/docs/the-new-architecture/using-codegen#configuring-codegen';\n\n/**\n * Currently, running react-native codegen generates java files with package name `com.facebook.fbreact.specs`.\n * This is a known issue in react-native itself.\n * You can find the relevant line here: https://github.com/facebook/react-native/blob/dc460147bb00d6f912cc0a829f8040d85faeeb13/packages/react-native/scripts/codegen/generate-artifacts-executor.js#L459.\n * To workaround, this function renames the package name to the one provided in the codegenConfig.\n * @throws if codegenConfig.outputDir.android or codegenConfig.android.javaPackageName is not defined in package.json\n * @throws if the codegenAndroidPath does not exist\n */\nexport async function patchCodegenAndroidPackage(\n projectPath: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n packageJson: any,\n report: Report\n) {\n let codegenAndroidPath: string | undefined =\n packageJson.codegenConfig?.outputDir?.android;\n if (!codegenAndroidPath) {\n throw new Error(\n `Your package.json doesn't contain codegenConfig.outputDir.android. Please see ${CODEGEN_DOCS}`\n );\n }\n codegenAndroidPath = path.resolve(projectPath, codegenAndroidPath);\n\n if (!(await fs.pathExists(codegenAndroidPath))) {\n throw new Error(\n `The codegen android path defined in your package.json: ${codegenAndroidPath} doesn't exist.`\n );\n }\n\n const codegenJavaPackageName: string | undefined =\n packageJson.codegenConfig.android.javaPackageName;\n if (!codegenJavaPackageName) {\n throw new Error(\n `Your package.json doesn't contain codegenConfig.android.javaPackageName. Please see ${CODEGEN_DOCS}`\n );\n }\n\n const codegenJavaPath = path.resolve(\n codegenAndroidPath,\n `java/com/facebook/fbreact/specs`\n );\n\n // If this issue is ever fixed in react-native, this check will prevent the patching from running.\n if (!(await fs.pathExists(codegenJavaPath))) {\n report.info(\n `Could not find ${kleur.blue(\n path.relative(projectPath, codegenJavaPath)\n )}. Skipping patching codegen java files.`\n );\n return;\n }\n\n const javaFiles = await fs.readdir(codegenJavaPath);\n\n await Promise.all(\n javaFiles.map(async (file) => {\n const filePath = path.resolve(codegenJavaPath, file);\n const fileContent = await fs.readFile(filePath, 'utf8');\n\n const newFileContent = fileContent.replace(\n 'package com.facebook.fbreact.specs',\n `package ${codegenJavaPackageName}`\n );\n\n await fs.writeFile(filePath, newFileContent);\n })\n );\n\n const newPackagePath = path.resolve(\n codegenAndroidPath,\n 'java',\n codegenJavaPackageName.replace(/\\./g, path.sep)\n );\n\n if (!(await fs.pathExists(newPackagePath))) {\n await fs.mkdir(newPackagePath, { recursive: true });\n }\n\n await Promise.all(\n javaFiles.map(async (file) => {\n const filePath = path.resolve(codegenJavaPath, file);\n const newFilePath = path.resolve(newPackagePath, file);\n\n await fs.rename(filePath, newFilePath);\n })\n );\n\n if (\n await fs.pathExists(\n path.resolve(codegenAndroidPath, 'java/com/facebook/react/viewmanagers')\n )\n ) {\n // Keep the view managers\n await fs.rm(path.resolve(codegenAndroidPath, 'java/com/facebook/fbreact'), {\n recursive: true,\n });\n } else {\n // Delete the entire facebook namespace\n await fs.rm(path.resolve(codegenAndroidPath, 'java/com/facebook'), {\n recursive: true,\n });\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AAA0B,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEnB,MAAMG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AMxB,gBAAE,CAAC2B,EAAE,CAAC7B,aAAI,CAACC,OAAO,CAACN,kBAAkB,EAAE,mBAAmB,CAAC,EAAE;MACjE+B,SAAS,EAAE;IACb,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
|
-
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
5
|
-
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
6
|
-
var _patchCodegenAndroidPackage = require("./patchCodegenAndroidPackage");
|
|
7
|
-
var _mockFs = _interopRequireDefault(require("mock-fs"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
const mockPackageJson = {
|
|
10
|
-
codegenConfig: {
|
|
11
|
-
outputDir: {
|
|
12
|
-
android: 'android/generated'
|
|
13
|
-
},
|
|
14
|
-
android: {
|
|
15
|
-
javaPackageName: 'com.bobtest'
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
const mockReport = {
|
|
20
|
-
info: console.log,
|
|
21
|
-
warn: console.log,
|
|
22
|
-
error: console.error,
|
|
23
|
-
success: console.log
|
|
24
|
-
};
|
|
25
|
-
const mockJavaModuleSpec = `
|
|
26
|
-
/**
|
|
27
|
-
* Some comment
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
package com.facebook.fbreact.specs;
|
|
31
|
-
|
|
32
|
-
import com.example.exampleimport;
|
|
33
|
-
|
|
34
|
-
class SomeClass {
|
|
35
|
-
public void someMethod() {
|
|
36
|
-
// some code
|
|
37
|
-
}
|
|
38
|
-
}`;
|
|
39
|
-
const mockJavaViewSpec = `
|
|
40
|
-
/**
|
|
41
|
-
* Some comment
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
package com.facebook.react.viewmanagers;
|
|
45
|
-
|
|
46
|
-
public interface SomeInterface<T extends View> {
|
|
47
|
-
void setColor(T view, @Nullable String value);
|
|
48
|
-
}
|
|
49
|
-
`;
|
|
50
|
-
const mockProjectPath = _nodePath.default.resolve(__dirname, 'mockProject');
|
|
51
|
-
const mockCodegenModuleSpecsPath = _nodePath.default.resolve(mockProjectPath, 'android/generated/java/com/facebook/fbreact/specs');
|
|
52
|
-
const mockCodegenViewSpecsPath = _nodePath.default.resolve(mockProjectPath, 'android/generated/java/com/facebook/react/viewmanagers');
|
|
53
|
-
(0, _vitest.describe)('patchCodegenAndroidPackage', () => {
|
|
54
|
-
(0, _vitest.beforeEach)(() => {
|
|
55
|
-
(0, _mockFs.default)({
|
|
56
|
-
[mockProjectPath]: {
|
|
57
|
-
'package.json': JSON.stringify(mockPackageJson)
|
|
58
|
-
},
|
|
59
|
-
[mockCodegenModuleSpecsPath]: {
|
|
60
|
-
'NativeBobtestSpec.java': mockJavaModuleSpec
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
(0, _vitest.afterEach)(() => {
|
|
65
|
-
_mockFs.default.restore();
|
|
66
|
-
});
|
|
67
|
-
(0, _vitest.test)('moves the files to correct dir', async () => {
|
|
68
|
-
await (0, _patchCodegenAndroidPackage.patchCodegenAndroidPackage)(mockProjectPath, mockPackageJson, mockReport);
|
|
69
|
-
const expectedDir = _nodePath.default.resolve(mockProjectPath, 'android/generated/java/com/bobtest');
|
|
70
|
-
(0, _vitest.expect)(await _fsExtra.default.pathExists(expectedDir)).toBe(true);
|
|
71
|
-
});
|
|
72
|
-
(0, _vitest.test)('replaces the package name in the files', async () => {
|
|
73
|
-
await (0, _patchCodegenAndroidPackage.patchCodegenAndroidPackage)(mockProjectPath, mockPackageJson, mockReport);
|
|
74
|
-
const expectedDir = _nodePath.default.resolve(mockProjectPath, 'android/generated/java/com/bobtest');
|
|
75
|
-
const expectedFile = _nodePath.default.resolve(expectedDir, 'NativeBobtestSpec.java');
|
|
76
|
-
const fileContent = await _fsExtra.default.readFile(expectedFile, 'utf8');
|
|
77
|
-
(0, _vitest.expect)(fileContent).toContain('package com.bobtest;');
|
|
78
|
-
});
|
|
79
|
-
(0, _vitest.test)('removes the old package dir', async () => {
|
|
80
|
-
await (0, _patchCodegenAndroidPackage.patchCodegenAndroidPackage)(mockProjectPath, mockPackageJson, mockReport);
|
|
81
|
-
(0, _vitest.expect)(await _fsExtra.default.pathExists(mockCodegenModuleSpecsPath)).toBe(false);
|
|
82
|
-
});
|
|
83
|
-
(0, _vitest.test)("doesn't delete the view manager specs", async () => {
|
|
84
|
-
const mockPackageJsonWithTypeAll = {
|
|
85
|
-
...mockPackageJson,
|
|
86
|
-
codegenConfig: {
|
|
87
|
-
...mockPackageJson.codegenConfig,
|
|
88
|
-
type: 'all'
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
(0, _mockFs.default)({
|
|
92
|
-
[mockProjectPath]: {
|
|
93
|
-
'package.json': JSON.stringify(mockPackageJsonWithTypeAll)
|
|
94
|
-
},
|
|
95
|
-
[mockCodegenModuleSpecsPath]: {
|
|
96
|
-
'NativeBobtestSpec.java': mockJavaModuleSpec
|
|
97
|
-
},
|
|
98
|
-
[mockCodegenViewSpecsPath]: {
|
|
99
|
-
'BobtestViewManagerInterface.java': mockJavaViewSpec
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
await (0, _patchCodegenAndroidPackage.patchCodegenAndroidPackage)(mockProjectPath, mockPackageJsonWithTypeAll, mockReport);
|
|
103
|
-
(0, _vitest.expect)(await _fsExtra.default.pathExists(_nodePath.default.join(mockCodegenViewSpecsPath, 'BobtestViewManagerInterface.java'))).toBeTruthy();
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
//# sourceMappingURL=patchCodegenAndroidPackage.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"patchCodegenAndroidPackage.test.js","names":["_vitest","require","_fsExtra","_interopRequireDefault","_nodePath","_patchCodegenAndroidPackage","_mockFs","e","__esModule","default","mockPackageJson","codegenConfig","outputDir","android","javaPackageName","mockReport","info","console","log","warn","error","success","mockJavaModuleSpec","mockJavaViewSpec","mockProjectPath","path","resolve","__dirname","mockCodegenModuleSpecsPath","mockCodegenViewSpecsPath","describe","beforeEach","mockfs","JSON","stringify","afterEach","restore","test","patchCodegenAndroidPackage","expectedDir","expect","fs","pathExists","toBe","expectedFile","fileContent","readFile","toContain","mockPackageJsonWithTypeAll","type","join","toBeTruthy"],"sources":["../../../../src/targets/codegen/patches/patchCodegenAndroidPackage.test.ts"],"sourcesContent":["import { expect, test, describe, beforeEach, afterEach } from 'vitest';\nimport fs from 'fs-extra';\nimport path from 'node:path';\nimport { patchCodegenAndroidPackage } from './patchCodegenAndroidPackage';\nimport mockfs from 'mock-fs';\nimport type { Report } from '../../../types';\n\nconst mockPackageJson = {\n codegenConfig: {\n outputDir: {\n android: 'android/generated',\n },\n android: {\n javaPackageName: 'com.bobtest',\n },\n },\n};\n\nconst mockReport: Report = {\n info: console.log,\n warn: console.log,\n error: console.error,\n success: console.log,\n};\n\nconst mockJavaModuleSpec = `\n/**\n * Some comment\n */\n\npackage com.facebook.fbreact.specs;\n\nimport com.example.exampleimport;\n\nclass SomeClass {\n public void someMethod() {\n // some code\n }\n}`;\n\nconst mockJavaViewSpec = `\n/**\n * Some comment\n */\n\npackage com.facebook.react.viewmanagers;\n\npublic interface SomeInterface<T extends View> {\n void setColor(T view, @Nullable String value);\n}\n`;\n\nconst mockProjectPath = path.resolve(__dirname, 'mockProject');\nconst mockCodegenModuleSpecsPath = path.resolve(\n mockProjectPath,\n 'android/generated/java/com/facebook/fbreact/specs'\n);\nconst mockCodegenViewSpecsPath = path.resolve(\n mockProjectPath,\n 'android/generated/java/com/facebook/react/viewmanagers'\n);\n\ndescribe('patchCodegenAndroidPackage', () => {\n beforeEach(() => {\n mockfs({\n [mockProjectPath]: {\n 'package.json': JSON.stringify(mockPackageJson),\n },\n [mockCodegenModuleSpecsPath]: {\n 'NativeBobtestSpec.java': mockJavaModuleSpec,\n },\n });\n });\n\n afterEach(() => {\n mockfs.restore();\n });\n\n test('moves the files to correct dir', async () => {\n await patchCodegenAndroidPackage(\n mockProjectPath,\n mockPackageJson,\n mockReport\n );\n\n const expectedDir = path.resolve(\n mockProjectPath,\n 'android/generated/java/com/bobtest'\n );\n\n expect(await fs.pathExists(expectedDir)).toBe(true);\n });\n\n test('replaces the package name in the files', async () => {\n await patchCodegenAndroidPackage(\n mockProjectPath,\n mockPackageJson,\n mockReport\n );\n\n const expectedDir = path.resolve(\n mockProjectPath,\n 'android/generated/java/com/bobtest'\n );\n\n const expectedFile = path.resolve(expectedDir, 'NativeBobtestSpec.java');\n\n const fileContent = await fs.readFile(expectedFile, 'utf8');\n\n expect(fileContent).toContain('package com.bobtest;');\n });\n\n test('removes the old package dir', async () => {\n await patchCodegenAndroidPackage(\n mockProjectPath,\n mockPackageJson,\n mockReport\n );\n\n expect(await fs.pathExists(mockCodegenModuleSpecsPath)).toBe(false);\n });\n\n test(\"doesn't delete the view manager specs\", async () => {\n const mockPackageJsonWithTypeAll = {\n ...mockPackageJson,\n codegenConfig: {\n ...mockPackageJson.codegenConfig,\n type: 'all',\n },\n };\n\n mockfs({\n [mockProjectPath]: {\n 'package.json': JSON.stringify(mockPackageJsonWithTypeAll),\n },\n [mockCodegenModuleSpecsPath]: {\n 'NativeBobtestSpec.java': mockJavaModuleSpec,\n },\n [mockCodegenViewSpecsPath]: {\n 'BobtestViewManagerInterface.java': mockJavaViewSpec,\n },\n });\n\n await patchCodegenAndroidPackage(\n mockProjectPath,\n mockPackageJsonWithTypeAll,\n mockReport\n );\n\n expect(\n await fs.pathExists(\n path.join(mockCodegenViewSpecsPath, 'BobtestViewManagerInterface.java')\n )\n ).toBeTruthy();\n });\n});\n"],"mappings":";;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,SAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,I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,IAAI,EAAE;MACR;IACF,CAAC;IAED,IAAAjB,eAAM,EAAC;MACL,CAACR,eAAe,GAAG;QACjB,cAAc,EAAES,IAAI,CAACC,SAAS,CAACc,0BAA0B;MAC3D,CAAC;MACD,CAACpB,0BAA0B,GAAG;QAC5B,wBAAwB,EAAEN;MAC5B,CAAC;MACD,CAACO,wBAAwB,GAAG;QAC1B,kCAAkC,EAAEN;MACtC;IACF,CAAC,CAAC;IAEF,MAAM,IAAAe,sDAA0B,EAC9Bd,eAAe,EACfwB,0BAA0B,EAC1BjC,UACF,CAAC;IAED,IAAAyB,cAAM,EACJ,MAAMC,gBAAE,CAACC,UAAU,CACjBjB,iBAAI,CAACyB,IAAI,CAACrB,wBAAwB,EAAE,kCAAkC,CACxE,CACF,CAAC,CAACsB,UAAU,CAAC,CAAC;EAChB,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getCodegenCLISourceSupport = getCodegenCLISourceSupport;
|
|
7
|
-
exports.removeCodegenAppLevelCode = removeCodegenAppLevelCode;
|
|
8
|
-
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
9
|
-
var _path = _interopRequireDefault(require("path"));
|
|
10
|
-
var _patchCodegenAndroidPackage = require("./patchCodegenAndroidPackage");
|
|
11
|
-
var _spawn = require("../../../utils/spawn");
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
const FILES_TO_REMOVE = ['RCTAppDependencyProvider.h', 'RCTAppDependencyProvider.mm', 'RCTModulesConformingToProtocolsProvider.h', 'RCTModulesConformingToProtocolsProvider.mm', 'RCTThirdPartyComponentsProvider.h', 'RCTThirdPartyComponentsProvider.mm', 'ReactAppDependencyProvider.podspec'];
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* With React Native 0.77, calling `@react-native-community/cli codegen` generates
|
|
17
|
-
* some app level source files such as `RCTAppDependencyProvider.mm`.
|
|
18
|
-
* These files are supposed to be only generated for apps
|
|
19
|
-
* but the cli misbehaves and generates them for all sorts of projects.
|
|
20
|
-
* You can find the relevant PR here: https://github.com/facebook/react-native/pull/47650
|
|
21
|
-
* This patch can be removed when this gets fixed in React Native.
|
|
22
|
-
*/
|
|
23
|
-
async function removeCodegenAppLevelCode(projectPath,
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
-
packageJson) {
|
|
26
|
-
const codegenAndroidPathSetting = packageJson.codegenConfig?.outputDir?.android;
|
|
27
|
-
if (!codegenAndroidPathSetting) {
|
|
28
|
-
throw new Error(`Your package.json doesn't contain codegenConfig.outputDir.android. Please see ${_patchCodegenAndroidPackage.CODEGEN_DOCS}`);
|
|
29
|
-
}
|
|
30
|
-
const codegenAndroidPath = _path.default.resolve(projectPath, codegenAndroidPathSetting);
|
|
31
|
-
if (!(await _fsExtra.default.pathExists(codegenAndroidPath))) {
|
|
32
|
-
throw new Error(`The codegen android path defined in your package.json: ${codegenAndroidPath} doesnt' exist.`);
|
|
33
|
-
}
|
|
34
|
-
const codegenIosPathSetting = packageJson.codegenConfig?.outputDir?.ios;
|
|
35
|
-
if (!codegenIosPathSetting) {
|
|
36
|
-
throw new Error(`Your package.json doesn't contain codegenConfig.outputDir.ios. Please see ${_patchCodegenAndroidPackage.CODEGEN_DOCS}`);
|
|
37
|
-
}
|
|
38
|
-
const codegenIosPath = _path.default.resolve(projectPath, codegenIosPathSetting);
|
|
39
|
-
if (!(await _fsExtra.default.pathExists(codegenAndroidPath))) {
|
|
40
|
-
throw new Error(`The codegen iOS path defined in your package.json: ${codegenIosPathSetting} doesnt' exist.`);
|
|
41
|
-
}
|
|
42
|
-
const androidPromises = FILES_TO_REMOVE.map(async fileName => _fsExtra.default.rm(_path.default.join(codegenAndroidPath, fileName)));
|
|
43
|
-
const iosPromises = FILES_TO_REMOVE.map(async fileName => _fsExtra.default.rm(_path.default.join(codegenIosPath, fileName)));
|
|
44
|
-
await Promise.allSettled([...androidPromises, ...iosPromises]);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Codegen generates a different set of files if the target is an app instead.
|
|
49
|
-
* The following commit adds support for a --source argument to support calling codegen as a library:
|
|
50
|
-
* https://github.com/facebook/react-native/commit/98b8f178110472e5fed97de80766c03b0b5e988c
|
|
51
|
-
* Here we just check if the --source argument is supported.
|
|
52
|
-
*/
|
|
53
|
-
async function getCodegenCLISourceSupport() {
|
|
54
|
-
const codegenCLIHelpOutput = await (0, _spawn.spawn)('npx', ['@react-native-community/cli', 'codegen', '--help']);
|
|
55
|
-
return codegenCLIHelpOutput.includes('--source');
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=removeCodegenAppLevelCode.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"removeCodegenAppLevelCode.js","names":["_fsExtra","_interopRequireDefault","require","_path","_patchCodegenAndroidPackage","_spawn","e","__esModule","default","FILES_TO_REMOVE","removeCodegenAppLevelCode","projectPath","packageJson","codegenAndroidPathSetting","codegenConfig","outputDir","android","Error","CODEGEN_DOCS","codegenAndroidPath","path","resolve","fs","pathExists","codegenIosPathSetting","ios","codegenIosPath","androidPromises","map","fileName","rm","join","iosPromises","Promise","allSettled","getCodegenCLISourceSupport","codegenCLIHelpOutput","spawn","includes"],"sources":["../../../../src/targets/codegen/patches/removeCodegenAppLevelCode.ts"],"sourcesContent":["import fs from 'fs-extra';\nimport path from 'path';\nimport { CODEGEN_DOCS } from './patchCodegenAndroidPackage';\nimport { spawn } from '../../../utils/spawn';\n\nconst FILES_TO_REMOVE = [\n 'RCTAppDependencyProvider.h',\n 'RCTAppDependencyProvider.mm',\n 'RCTModulesConformingToProtocolsProvider.h',\n 'RCTModulesConformingToProtocolsProvider.mm',\n 'RCTThirdPartyComponentsProvider.h',\n 'RCTThirdPartyComponentsProvider.mm',\n 'ReactAppDependencyProvider.podspec',\n];\n\n/**\n * With React Native 0.77, calling `@react-native-community/cli codegen` generates\n * some app level source files such as `RCTAppDependencyProvider.mm`.\n * These files are supposed to be only generated for apps\n * but the cli misbehaves and generates them for all sorts of projects.\n * You can find the relevant PR here: https://github.com/facebook/react-native/pull/47650\n * This patch can be removed when this gets fixed in React Native.\n */\nexport async function removeCodegenAppLevelCode(\n projectPath: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n packageJson: any\n) {\n const codegenAndroidPathSetting: string | undefined =\n packageJson.codegenConfig?.outputDir?.android;\n if (!codegenAndroidPathSetting) {\n throw new Error(\n `Your package.json doesn't contain codegenConfig.outputDir.android. Please see ${CODEGEN_DOCS}`\n );\n }\n const codegenAndroidPath = path.resolve(\n projectPath,\n codegenAndroidPathSetting\n );\n\n if (!(await fs.pathExists(codegenAndroidPath))) {\n throw new Error(\n `The codegen android path defined in your package.json: ${codegenAndroidPath} doesnt' exist.`\n );\n }\n\n const codegenIosPathSetting: string | undefined =\n packageJson.codegenConfig?.outputDir?.ios;\n if (!codegenIosPathSetting) {\n throw new Error(\n `Your package.json doesn't contain codegenConfig.outputDir.ios. Please see ${CODEGEN_DOCS}`\n );\n }\n const codegenIosPath = path.resolve(projectPath, codegenIosPathSetting);\n\n if (!(await fs.pathExists(codegenAndroidPath))) {\n throw new Error(\n `The codegen iOS path defined in your package.json: ${codegenIosPathSetting} doesnt' exist.`\n );\n }\n\n const androidPromises = FILES_TO_REMOVE.map(async (fileName) =>\n fs.rm(path.join(codegenAndroidPath, fileName))\n );\n\n const iosPromises = FILES_TO_REMOVE.map(async (fileName) =>\n fs.rm(path.join(codegenIosPath, fileName))\n );\n\n await Promise.allSettled([...androidPromises, ...iosPromises]);\n}\n\n/**\n * Codegen generates a different set of files if the target is an app instead.\n * The following commit adds support for a --source argument to support calling codegen as a library:\n * https://github.com/facebook/react-native/commit/98b8f178110472e5fed97de80766c03b0b5e988c\n * Here we just check if the --source argument is supported.\n */\nexport async function getCodegenCLISourceSupport(): Promise<boolean> {\n const codegenCLIHelpOutput = await spawn('npx', [\n '@react-native-community/cli',\n 'codegen',\n '--help',\n ]);\n return codegenCLIHelpOutput.includes('--source');\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,2BAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAA6C,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE7C,MAAMG,eAAe,GAAG,CACtB,4BAA4B,EAC5B,6BAA6B,EAC7B,2CAA2C,EAC3C,4CAA4C,EAC5C,mCAAmC,EACnC,oCAAoC,EACpC,oCAAoC,CACrC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeC,yBAAyBA,CAC7CC,WAAmB;AACnB;AACAC,WAAgB,EAChB;EACA,MAAMC,yBAA6C,GACjDD,WAAW,CAACE,aAAa,EAAEC,SAAS,EAAEC,OAAO;EAC/C,IAAI,CAACH,yBAAyB,EAAE;IAC9B,MAAM,IAAII,KAAK,CACb,iFAAiFC,wCAAY,EAC/F,CAAC;EACH;EACA,MAAMC,kBAAkB,GAAGC,aAAI,CAACC,OAAO,CACrCV,WAAW,EACXE,yBACF,CAAC;EAED,IAAI,EAAE,MAAMS,gBAAE,CAACC,UAAU,CAACJ,kBAAkB,CAAC,CAAC,EAAE;IAC9C,MAAM,IAAIF,KAAK,CACb,0DAA0DE,kBAAkB,iBAC9E,CAAC;EACH;EAEA,MAAMK,qBAAyC,GAC7CZ,WAAW,CAACE,aAAa,EAAEC,SAAS,EAAEU,GAAG;EAC3C,IAAI,CAACD,qBAAqB,EAAE;IAC1B,MAAM,IAAIP,KAAK,CACb,6EAA6EC,wCAAY,EAC3F,CAAC;EACH;EACA,MAAMQ,cAAc,GAAGN,aAAI,CAACC,OAAO,CAACV,WAAW,EAAEa,qBAAqB,CAAC;EAEvE,IAAI,EAAE,MAAMF,gBAAE,CAACC,UAAU,CAACJ,kBAAkB,CAAC,CAAC,EAAE;IAC9C,MAAM,IAAIF,KAAK,CACb,sDAAsDO,qBAAqB,iBAC7E,CAAC;EACH;EAEA,MAAMG,eAAe,GAAGlB,eAAe,CAACmB,GAAG,CAAC,MAAOC,QAAQ,IACzDP,gBAAE,CAACQ,EAAE,CAACV,aAAI,CAACW,IAAI,CAACZ,kBAAkB,EAAEU,QAAQ,CAAC,CAC/C,CAAC;EAED,MAAMG,WAAW,GAAGvB,eAAe,CAACmB,GAAG,CAAC,MAAOC,QAAQ,IACrDP,gBAAE,CAACQ,EAAE,CAACV,aAAI,CAACW,IAAI,CAACL,cAAc,EAAEG,QAAQ,CAAC,CAC3C,CAAC;EAED,MAAMI,OAAO,CAACC,UAAU,CAAC,CAAC,GAAGP,eAAe,EAAE,GAAGK,WAAW,CAAC,CAAC;AAChE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeG,0BAA0BA,CAAA,EAAqB;EACnE,MAAMC,oBAAoB,GAAG,MAAM,IAAAC,YAAK,EAAC,KAAK,EAAE,CAC9C,6BAA6B,EAC7B,SAAS,EACT,QAAQ,CACT,CAAC;EACF,OAAOD,oBAAoB,CAACE,QAAQ,CAAC,UAAU,CAAC;AAClD","ignoreList":[]}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
|
-
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
5
|
-
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
6
|
-
var _removeCodegenAppLevelCode = require("./removeCodegenAppLevelCode");
|
|
7
|
-
var _mockFs = _interopRequireDefault(require("mock-fs"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
const mockPackageJson = {
|
|
10
|
-
codegenConfig: {
|
|
11
|
-
outputDir: {
|
|
12
|
-
android: 'android/generated',
|
|
13
|
-
ios: 'ios/generated'
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
const mockProjectPath = _nodePath.default.resolve(__dirname, 'mockProject');
|
|
18
|
-
(0, _vitest.describe)('patchCodegenAndroidPackage', () => {
|
|
19
|
-
(0, _vitest.beforeEach)(() => {
|
|
20
|
-
(0, _mockFs.default)({
|
|
21
|
-
[mockProjectPath]: {
|
|
22
|
-
'package.json': JSON.stringify(mockPackageJson),
|
|
23
|
-
'ios': {
|
|
24
|
-
generated: {
|
|
25
|
-
'RCTAppDependencyProvider.h': '',
|
|
26
|
-
'RCTAppDependencyProvider.mm': '',
|
|
27
|
-
'RCTModulesConformingToProtocolsProvider.h': '',
|
|
28
|
-
'RCTModulesConformingToProtocolsProvider.mm': '',
|
|
29
|
-
'RCTThirdPartyComponentsProvider.h': '',
|
|
30
|
-
'RCTThirdPartyComponentsProvider.mm': '',
|
|
31
|
-
'ReactAppDependencyProvider.podspec': ''
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
'android': {
|
|
35
|
-
generated: {
|
|
36
|
-
'RCTAppDependencyProvider.h': '',
|
|
37
|
-
'RCTAppDependencyProvider.mm': '',
|
|
38
|
-
'RCTModulesConformingToProtocolsProvider.h': '',
|
|
39
|
-
'RCTModulesConformingToProtocolsProvider.mm': '',
|
|
40
|
-
'RCTThirdPartyComponentsProvider.h': '',
|
|
41
|
-
'RCTThirdPartyComponentsProvider.mm': '',
|
|
42
|
-
'ReactAppDependencyProvider.podspec': ''
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
(0, _vitest.afterEach)(() => {
|
|
49
|
-
_mockFs.default.restore();
|
|
50
|
-
});
|
|
51
|
-
(0, _vitest.test)('removes the duplicate iOS files', async () => {
|
|
52
|
-
await (0, _removeCodegenAppLevelCode.removeCodegenAppLevelCode)(mockProjectPath, mockPackageJson);
|
|
53
|
-
(0, _vitest.expect)((await _fsExtra.default.promises.readdir(_nodePath.default.join(mockProjectPath, 'ios', 'generated'))).length).toBe(0);
|
|
54
|
-
});
|
|
55
|
-
(0, _vitest.test)('removes the unnecessary Android files', async () => {
|
|
56
|
-
await (0, _removeCodegenAppLevelCode.removeCodegenAppLevelCode)(mockProjectPath, mockPackageJson);
|
|
57
|
-
(0, _vitest.expect)((await _fsExtra.default.promises.readdir(_nodePath.default.join(mockProjectPath, 'android', 'generated'))).length).toBe(0);
|
|
58
|
-
});
|
|
59
|
-
(0, _vitest.test)("doesn't crash the process when there are no files to remove", async () => {
|
|
60
|
-
(0, _mockFs.default)({
|
|
61
|
-
[mockProjectPath]: {
|
|
62
|
-
'package.json': JSON.stringify(mockPackageJson),
|
|
63
|
-
'ios': {
|
|
64
|
-
generated: {
|
|
65
|
-
someRandomFile: ''
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
'android': {
|
|
69
|
-
generated: {
|
|
70
|
-
someRandomFile: ''
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
await (0, _vitest.expect)((0, _removeCodegenAppLevelCode.removeCodegenAppLevelCode)(mockProjectPath, mockPackageJson)).resolves.not.toThrow();
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
//# sourceMappingURL=removeCodegenAppLevelCode.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"removeCodegenAppLevelCode.test.js","names":["_vitest","require","_fsExtra","_interopRequireDefault","_nodePath","_removeCodegenAppLevelCode","_mockFs","e","__esModule","default","mockPackageJson","codegenConfig","outputDir","android","ios","mockProjectPath","path","resolve","__dirname","describe","beforeEach","mockfs","JSON","stringify","generated","afterEach","restore","test","removeCodegenAppLevelCode","expect","fs","promises","readdir","join","length","toBe","someRandomFile","resolves","not","toThrow"],"sources":["../../../../src/targets/codegen/patches/removeCodegenAppLevelCode.test.ts"],"sourcesContent":["import { expect, describe, beforeEach, afterEach, test } from 'vitest';\nimport fs from 'fs-extra';\nimport path from 'node:path';\nimport { removeCodegenAppLevelCode } from './removeCodegenAppLevelCode';\nimport mockfs from 'mock-fs';\n\nconst mockPackageJson = {\n codegenConfig: {\n outputDir: {\n android: 'android/generated',\n ios: 'ios/generated',\n },\n },\n};\n\nconst mockProjectPath = path.resolve(__dirname, 'mockProject');\n\ndescribe('patchCodegenAndroidPackage', () => {\n beforeEach(() => {\n mockfs({\n [mockProjectPath]: {\n 'package.json': JSON.stringify(mockPackageJson),\n 'ios': {\n generated: {\n 'RCTAppDependencyProvider.h': '',\n 'RCTAppDependencyProvider.mm': '',\n 'RCTModulesConformingToProtocolsProvider.h': '',\n 'RCTModulesConformingToProtocolsProvider.mm': '',\n 'RCTThirdPartyComponentsProvider.h': '',\n 'RCTThirdPartyComponentsProvider.mm': '',\n 'ReactAppDependencyProvider.podspec': '',\n },\n },\n 'android': {\n generated: {\n 'RCTAppDependencyProvider.h': '',\n 'RCTAppDependencyProvider.mm': '',\n 'RCTModulesConformingToProtocolsProvider.h': '',\n 'RCTModulesConformingToProtocolsProvider.mm': '',\n 'RCTThirdPartyComponentsProvider.h': '',\n 'RCTThirdPartyComponentsProvider.mm': '',\n 'ReactAppDependencyProvider.podspec': '',\n },\n },\n },\n });\n });\n\n afterEach(() => {\n mockfs.restore();\n });\n\n test('removes the duplicate iOS files', async () => {\n await removeCodegenAppLevelCode(mockProjectPath, mockPackageJson);\n\n expect(\n (\n await fs.promises.readdir(\n path.join(mockProjectPath, 'ios', 'generated')\n )\n ).length\n ).toBe(0);\n });\n\n test('removes the unnecessary Android files', async () => {\n await removeCodegenAppLevelCode(mockProjectPath, mockPackageJson);\n\n expect(\n (\n await fs.promises.readdir(\n path.join(mockProjectPath, 'android', 'generated')\n )\n ).length\n ).toBe(0);\n });\n\n test(\"doesn't crash the process when there are no files to remove\", async () => {\n mockfs({\n [mockProjectPath]: {\n 'package.json': JSON.stringify(mockPackageJson),\n 'ios': {\n generated: {\n someRandomFile: '',\n },\n },\n 'android': {\n generated: {\n someRandomFile: '',\n },\n },\n },\n });\n\n await expect(\n removeCodegenAppLevelCode(mockProjectPath, mockPackageJson)\n ).resolves.not.toThrow();\n });\n});\n"],"mappings":";;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,SAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,0BAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAH,sBAAA,CAAAF,OAAA;AAA6B,SAAAE,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE7B,MAAMG,eAAe,GAAG;EACtBC,aAAa,EAAE;IACbC,SAAS,EAAE;MACTC,OAAO,EAAE,mBAAmB;MAC5BC,GAAG,EAAE;IACP;EACF;AACF,CAAC;AAED,MAAMC,eAAe,GAAGC,iBAAI,CAACC,OAAO,CAACC,SAAS,EAAE,aAAa,CAAC;AAE9D,IAAAC,gBAAQ,EAAC,4BAA4B,EAAE,MAAM;EAC3C,IAAAC,kBAAU,EAAC,MAAM;IACf,IAAAC,eAAM,EAAC;MACL,CAACN,eAAe,GAAG;QACjB,cAAc,EAAEO,IAAI,CAACC,SAAS,CAACb,eAAe,CAAC;QAC/C,KAAK,EAAE;UACLc,SAAS,EAAE;YACT,4BAA4B,EAAE,EAAE;YAChC,6BAA6B,EAAE,EAAE;YACjC,2CAA2C,EAAE,EAAE;YAC/C,4CAA4C,EAAE,EAAE;YAChD,mCAAmC,EAAE,EAAE;YACvC,oCAAoC,EAAE,EAAE;YACxC,oCAAoC,EAAE;UACxC;QACF,CAAC;QACD,SAAS,EAAE;UAC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AE;YACTY,cAAc,EAAE;UAClB;QACF;MACF;IACF,CAAC,CAAC;IAEF,MAAM,IAAAP,cAAM,EACV,IAAAD,oDAAyB,EAACb,eAAe,EAAEL,eAAe,CAC5D,CAAC,CAAC2B,QAAQ,CAACC,GAAG,CAACC,OAAO,CAAC,CAAC;EAC1B,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
package/lib/targets/commonjs.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = build;
|
|
7
|
-
var _path = _interopRequireDefault(require("path"));
|
|
8
|
-
var _kleur = _interopRequireDefault(require("kleur"));
|
|
9
|
-
var _del = _interopRequireDefault(require("del"));
|
|
10
|
-
var _compile = _interopRequireDefault(require("../utils/compile"));
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
async function build({
|
|
13
|
-
root,
|
|
14
|
-
source,
|
|
15
|
-
output,
|
|
16
|
-
exclude,
|
|
17
|
-
options,
|
|
18
|
-
variants,
|
|
19
|
-
report
|
|
20
|
-
}) {
|
|
21
|
-
report.info(`Cleaning up previous build at ${_kleur.default.blue(_path.default.relative(root, output))}`);
|
|
22
|
-
await (0, _del.default)([output]);
|
|
23
|
-
await (0, _compile.default)({
|
|
24
|
-
...options,
|
|
25
|
-
variants,
|
|
26
|
-
root,
|
|
27
|
-
source,
|
|
28
|
-
output,
|
|
29
|
-
exclude,
|
|
30
|
-
modules: 'commonjs',
|
|
31
|
-
report
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=commonjs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commonjs.js","names":["_path","_interopRequireDefault","require","_kleur","_del","_compile","e","__esModule","default","build","root","source","output","exclude","options","variants","report","info","kleur","blue","path","relative","del","compile","modules"],"sources":["../../src/targets/commonjs.ts"],"sourcesContent":["import path from 'path';\nimport kleur from 'kleur';\nimport del from 'del';\nimport compile, { type CompileOptions } from '../utils/compile';\nimport type { Input, Variants } from '../types';\n\ntype Options = Input & {\n options?: CompileOptions;\n variants: Variants;\n exclude: string;\n};\n\nexport default async function build({\n root,\n source,\n output,\n exclude,\n options,\n variants,\n report,\n}: Options) {\n report.info(\n `Cleaning up previous build at ${kleur.blue(path.relative(root, output))}`\n );\n\n await del([output]);\n\n await compile({\n ...options,\n variants,\n root,\n source,\n output,\n exclude,\n modules: 'commonjs',\n report,\n });\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,IAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAAgE,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AASjD,eAAeG,KAAKA,CAAC;EAClCC,IAAI;EACJC,MAAM;EACNC,MAAM;EACNC,OAAO;EACPC,OAAO;EACPC,QAAQ;EACRC;AACO,CAAC,EAAE;EACVA,MAAM,CAACC,IAAI,CACT,iCAAiCC,cAAK,CAACC,IAAI,CAACC,aAAI,CAACC,QAAQ,CAACX,IAAI,EAAEE,MAAM,CAAC,CAAC,EAC1E,CAAC;EAED,MAAM,IAAAU,YAAG,EAAC,CAACV,MAAM,CAAC,CAAC;EAEnB,MAAM,IAAAW,gBAAO,EAAC;IACZ,GAAGT,OAAO;IACVC,QAAQ;IACRL,IAAI;IACJC,MAAM;IACNC,MAAM;IACNC,OAAO;IACPW,OAAO,EAAE,UAAU;IACnBR;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
package/lib/targets/custom.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = customTarget;
|
|
7
|
-
var _kleur = _interopRequireDefault(require("kleur"));
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
10
|
-
var _spawn = require("../utils/spawn");
|
|
11
|
-
var _del = _interopRequireDefault(require("del"));
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
async function customTarget({
|
|
14
|
-
options,
|
|
15
|
-
root,
|
|
16
|
-
report
|
|
17
|
-
}) {
|
|
18
|
-
if (options?.script == null) {
|
|
19
|
-
throw new Error(`No 'script' was provided with the custom target. Example: ${_kleur.default.green('{["custom", { "script": "generateTypes" }}')}`);
|
|
20
|
-
}
|
|
21
|
-
const pathToClean = options.clean ? _path.default.relative(root, options.clean) : undefined;
|
|
22
|
-
if (pathToClean) {
|
|
23
|
-
report.info(`Cleaning up ${_kleur.default.blue(pathToClean)}`);
|
|
24
|
-
await (0, _del.default)([_path.default.resolve(root, pathToClean)]);
|
|
25
|
-
}
|
|
26
|
-
const packageManagerExecutable = process.env.npm_execpath ?? 'npm';
|
|
27
|
-
const packageManagerArgs = ['run', options.script];
|
|
28
|
-
|
|
29
|
-
// usr/bin/yarn -> yarn
|
|
30
|
-
const packageManagerName = _path.default.basename(packageManagerExecutable);
|
|
31
|
-
report.info(`Running ${_kleur.default.blue(packageManagerName)} ${_kleur.default.blue(packageManagerArgs.join(' '))}`);
|
|
32
|
-
await (0, _spawn.spawn)(packageManagerExecutable, packageManagerArgs, {
|
|
33
|
-
stdio: ['ignore', 'ignore', 'inherit']
|
|
34
|
-
});
|
|
35
|
-
report.success(`Ran the ${_kleur.default.blue(options.script)} script succesfully`);
|
|
36
|
-
if (options.clean && pathToClean && !(await _fsExtra.default.pathExists(pathToClean))) {
|
|
37
|
-
report.warn(`Custom target with the ${_kleur.default.blue(options.script)} script has ${_kleur.default.blue(options.clean)} as the ${_kleur.default.bold('clean')} option but this path wasn't created after running the script. Are you sure you've defined the ${_kleur.default.bold('clean')} path correctly?`);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=custom.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom.js","names":["_kleur","_interopRequireDefault","require","_path","_fsExtra","_spawn","_del","e","__esModule","default","customTarget","options","root","report","script","Error","kleur","green","pathToClean","clean","path","relative","undefined","info","blue","del","resolve","packageManagerExecutable","process","env","npm_execpath","packageManagerArgs","packageManagerName","basename","join","spawn","stdio","success","fs","pathExists","warn","bold"],"sources":["../../src/targets/custom.ts"],"sourcesContent":["import kleur from 'kleur';\nimport path from 'path';\nimport fs from 'fs-extra';\nimport type { Input } from '../types';\nimport { spawn } from '../utils/spawn';\nimport del from 'del';\n\ntype Options = Omit<Input, 'output'> & {\n options?: {\n script?: string;\n clean?: string;\n };\n};\n\nexport default async function customTarget({ options, root, report }: Options) {\n if (options?.script == null) {\n throw new Error(\n `No 'script' was provided with the custom target. Example: ${kleur.green(\n '{[\"custom\", { \"script\": \"generateTypes\" }}'\n )}`\n );\n }\n\n const pathToClean = options.clean\n ? path.relative(root, options.clean)\n : undefined;\n\n if (pathToClean) {\n report.info(`Cleaning up ${kleur.blue(pathToClean)}`);\n\n await del([path.resolve(root, pathToClean)]);\n }\n\n const packageManagerExecutable = process.env.npm_execpath ?? 'npm';\n const packageManagerArgs = ['run', options.script];\n\n // usr/bin/yarn -> yarn\n const packageManagerName = path.basename(packageManagerExecutable);\n report.info(\n `Running ${kleur.blue(packageManagerName)} ${kleur.blue(\n packageManagerArgs.join(' ')\n )}`\n );\n\n await spawn(packageManagerExecutable, packageManagerArgs, {\n stdio: ['ignore', 'ignore', 'inherit'],\n });\n\n report.success(`Ran the ${kleur.blue(options.script)} script succesfully`);\n\n if (options.clean && pathToClean && !(await fs.pathExists(pathToClean))) {\n report.warn(\n `Custom target with the ${kleur.blue(\n options.script\n )} script has ${kleur.blue(options.clean)} as the ${kleur.bold(\n 'clean'\n )} option but this path wasn't created after running the script. Are you sure you've defined the ${kleur.bold(\n 'clean'\n )} path correctly?`\n );\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAL,sBAAA,CAAAC,OAAA;AAAsB,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AASP,eAAeG,YAAYA,CAAC;EAAEC,OAAO;EAAEC,IAAI;EAAEC;AAAgB,CAAC,EAAE;EAC7E,IAAIF,OAAO,EAAEG,MAAM,IAAI,IAAI,EAAE;IAC3B,MAAM,IAAIC,KAAK,CACb,6DAA6DC,cAAK,CAACC,KAAK,CACtE,4CACF,CAAC,EACH,CAAC;EACH;EAEA,MAAMC,WAAW,GAAGP,OAAO,CAACQ,KAAK,GAC7BC,aAAI,CAACC,QAAQ,CAACT,IAAI,EAAED,OAAO,CAACQ,KAAK,CAAC,GAClCG,SAAS;EAEb,IAAIJ,WAAW,EAAE;IACfL,MAAM,CAACU,IAAI,CAAC,eAAeP,cAAK,CAACQ,IAAI,CAACN,WAAW,CAAC,EAAE,CAAC;IAErD,MAAM,IAAAO,YAAG,EAAC,CAACL,aAAI,CAACM,OAAO,CAACd,IAAI,EAAEM,WAAW,CAAC,CAAC,CAAC;EAC9C;EAEA,MAAMS,wBAAwB,GAAGC,OAAO,CAACC,GAAG,CAACC,YAAY,IAAI,KAAK;EAClE,MAAMC,kBAAkB,GAAG,CAAC,KAAK,EAAEpB,OAAO,CAACG,MAAM,CAAC;;EAElD;EACA,MAAMkB,kBAAkB,GAAGZ,aAAI,CAACa,QAAQ,CAACN,wBAAwB,CAAC;EAClEd,MAAM,CAACU,IAAI,CACT,WAAWP,cAAK,CAACQ,IAAI,CAACQ,kBAAkB,CAAC,IAAIhB,cAAK,CAACQ,IAAI,CACrDO,kBAAkB,CAACG,IAAI,CAAC,GAAG,CAC7B,CAAC,EACH,CAAC;EAED,MAAM,IAAAC,YAAK,EAACR,wBAAwB,EAAEI,kBAAkB,EAAE;IACxDK,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS;EACvC,CAAC,CAAC;EAEFvB,MAAM,CAACwB,OAAO,CAAC,WAAWrB,cAAK,CAACQ,IAAI,CAACb,OAAO,CAACG,MAAM,CAAC,qBAAqB,CAAC;EAE1E,IAAIH,OAAO,CAACQ,KAAK,IAAID,WAAW,IAAI,EAAE,MAAMoB,gBAAE,CAACC,UAAU,CAACrB,WAAW,CAAC,CAAC,EAAE;IACvEL,MAAM,CAAC2B,IAAI,CACT,0BAA0BxB,cAAK,CAACQ,IAAI,CAClCb,OAAO,CAACG,MACV,CAAC,eAAeE,cAAK,CAACQ,IAAI,CAACb,OAAO,CAACQ,KAAK,CAAC,WAAWH,cAAK,CAACyB,IAAI,CAC5D,OACF,CAAC,kGAAkGzB,cAAK,CAACyB,IAAI,CAC3G,OACF,CAAC,kBACH,CAAC;EACH;AACF","ignoreList":[]}
|
package/lib/targets/module.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = build;
|
|
7
|
-
var _path = _interopRequireDefault(require("path"));
|
|
8
|
-
var _kleur = _interopRequireDefault(require("kleur"));
|
|
9
|
-
var _del = _interopRequireDefault(require("del"));
|
|
10
|
-
var _compile = _interopRequireDefault(require("../utils/compile"));
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
async function build({
|
|
13
|
-
root,
|
|
14
|
-
source,
|
|
15
|
-
output,
|
|
16
|
-
exclude,
|
|
17
|
-
options,
|
|
18
|
-
variants,
|
|
19
|
-
report
|
|
20
|
-
}) {
|
|
21
|
-
report.info(`Cleaning up previous build at ${_kleur.default.blue(_path.default.relative(root, output))}`);
|
|
22
|
-
await (0, _del.default)([output]);
|
|
23
|
-
await (0, _compile.default)({
|
|
24
|
-
...options,
|
|
25
|
-
variants,
|
|
26
|
-
root,
|
|
27
|
-
source,
|
|
28
|
-
output,
|
|
29
|
-
exclude,
|
|
30
|
-
modules: 'preserve',
|
|
31
|
-
report
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","names":["_path","_interopRequireDefault","require","_kleur","_del","_compile","e","__esModule","default","build","root","source","output","exclude","options","variants","report","info","kleur","blue","path","relative","del","compile","modules"],"sources":["../../src/targets/module.ts"],"sourcesContent":["import path from 'path';\nimport kleur from 'kleur';\nimport del from 'del';\nimport compile, { type CompileOptions } from '../utils/compile';\nimport type { Input, Variants } from '../types';\n\ntype Options = Input & {\n options?: CompileOptions;\n variants: Variants;\n exclude: string;\n};\n\nexport default async function build({\n root,\n source,\n output,\n exclude,\n options,\n variants,\n report,\n}: Options) {\n report.info(\n `Cleaning up previous build at ${kleur.blue(path.relative(root, output))}`\n );\n\n await del([output]);\n\n await compile({\n ...options,\n variants,\n root,\n source,\n output,\n exclude,\n modules: 'preserve',\n report,\n });\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,IAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,QAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAAgE,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AASjD,eAAeG,KAAKA,CAAC;EAClCC,IAAI;EACJC,MAAM;EACNC,MAAM;EACNC,OAAO;EACPC,OAAO;EACPC,QAAQ;EACRC;AACO,CAAC,EAAE;EACVA,MAAM,CAACC,IAAI,CACT,iCAAiCC,cAAK,CAACC,IAAI,CAACC,aAAI,CAACC,QAAQ,CAACX,IAAI,EAAEE,MAAM,CAAC,CAAC,EAC1E,CAAC;EAED,MAAM,IAAAU,YAAG,EAAC,CAACV,MAAM,CAAC,CAAC;EAEnB,MAAM,IAAAW,gBAAO,EAAC;IACZ,GAAGT,OAAO;IACVC,QAAQ;IACRL,IAAI;IACJC,MAAM;IACNC,MAAM;IACNC,OAAO;IACPW,OAAO,EAAE,UAAU;IACnBR;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|