react-native-builder-bob 0.41.0 → 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/{configs/metro-config.js → lib/src/configs/metro-config.mjs} +3 -6
- 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 +15 -13
- package/configs/babel-config.js +0 -54
- package/configs/babel-preset.js +0 -69
- package/configs/vite-config.mjs +0 -62
- 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 -121
- package/lib/__fixtures__/project/code/$exports-input.js.map +0 -1
- package/lib/__fixtures__/project/code/$exports-output.js +0 -121
- 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 -141
- 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 -217
- 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
package/lib/init.js
DELETED
|
@@ -1,371 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.init = init;
|
|
7
|
-
var _path = _interopRequireDefault(require("path"));
|
|
8
|
-
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
9
|
-
var _kleur = _interopRequireDefault(require("kleur"));
|
|
10
|
-
var _dedent = _interopRequireDefault(require("dedent"));
|
|
11
|
-
var _isGitDirty = _interopRequireDefault(require("is-git-dirty"));
|
|
12
|
-
var _prompts = _interopRequireDefault(require("./utils/prompts"));
|
|
13
|
-
var _loadConfig = require("./utils/loadConfig");
|
|
14
|
-
var _package = _interopRequireDefault(require("../package.json"));
|
|
15
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
-
const FLOW_PRGAMA_REGEX = /\*?\s*@(flow)\b/m;
|
|
17
|
-
async function init() {
|
|
18
|
-
const root = process.cwd();
|
|
19
|
-
const projectPackagePath = _path.default.resolve(root, 'package.json');
|
|
20
|
-
if ((0, _isGitDirty.default)()) {
|
|
21
|
-
const {
|
|
22
|
-
shouldContinue
|
|
23
|
-
} = await (0, _prompts.default)({
|
|
24
|
-
type: 'confirm',
|
|
25
|
-
name: 'shouldContinue',
|
|
26
|
-
message: `The working directory is not clean.\n You should commit or stash your changes before configuring bob.\n Continue anyway?`,
|
|
27
|
-
initial: false
|
|
28
|
-
});
|
|
29
|
-
if (!shouldContinue) {
|
|
30
|
-
process.exit(0);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (!(await _fsExtra.default.pathExists(projectPackagePath))) {
|
|
34
|
-
throw new Error(`Couldn't find a 'package.json' file in '${root}'.\n Are you in a project folder?`);
|
|
35
|
-
}
|
|
36
|
-
const pkg = JSON.parse(await _fsExtra.default.readFile(projectPackagePath, 'utf-8'));
|
|
37
|
-
const result = (0, _loadConfig.loadConfig)(root);
|
|
38
|
-
if (result?.config && pkg.devDependencies && _package.default.name in pkg.devDependencies) {
|
|
39
|
-
const {
|
|
40
|
-
shouldContinue
|
|
41
|
-
} = await (0, _prompts.default)({
|
|
42
|
-
type: 'confirm',
|
|
43
|
-
name: 'shouldContinue',
|
|
44
|
-
message: `The project seems to be already configured with bob.\n Do you want to overwrite the existing configuration?`,
|
|
45
|
-
initial: false
|
|
46
|
-
});
|
|
47
|
-
if (!shouldContinue) {
|
|
48
|
-
process.exit(0);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
53
|
-
const {
|
|
54
|
-
source
|
|
55
|
-
} = await (0, _prompts.default)({
|
|
56
|
-
type: 'text',
|
|
57
|
-
name: 'source',
|
|
58
|
-
message: 'Where are your source files?',
|
|
59
|
-
initial: 'src',
|
|
60
|
-
validate: input => Boolean(input)
|
|
61
|
-
});
|
|
62
|
-
let entryFile;
|
|
63
|
-
if (await _fsExtra.default.pathExists(_path.default.join(root, source, 'index.js'))) {
|
|
64
|
-
entryFile = 'index.js';
|
|
65
|
-
} else if (await _fsExtra.default.pathExists(_path.default.join(root, source, 'index.ts'))) {
|
|
66
|
-
entryFile = 'index.ts';
|
|
67
|
-
} else if (await _fsExtra.default.pathExists(_path.default.join(root, source, 'index.tsx'))) {
|
|
68
|
-
entryFile = 'index.tsx';
|
|
69
|
-
}
|
|
70
|
-
if (!entryFile) {
|
|
71
|
-
throw new Error(`Couldn't find a 'index.js'. 'index.ts' or 'index.tsx' file under '${source}'.\n Please re-run the CLI after creating it.`);
|
|
72
|
-
}
|
|
73
|
-
pkg.devDependencies = Object.fromEntries([...Object.entries(pkg.devDependencies || {}), [_package.default.name, `^${_package.default.version}`]].sort(([a], [b]) => a.localeCompare(b)));
|
|
74
|
-
const questions = [{
|
|
75
|
-
type: 'text',
|
|
76
|
-
name: 'output',
|
|
77
|
-
message: 'Where do you want to generate the output files?',
|
|
78
|
-
initial: 'lib',
|
|
79
|
-
validate: input => Boolean(input)
|
|
80
|
-
}, {
|
|
81
|
-
type: 'multiselect',
|
|
82
|
-
name: 'targets',
|
|
83
|
-
message: 'Which targets do you want to build?',
|
|
84
|
-
choices: [{
|
|
85
|
-
title: 'module - for modern setups',
|
|
86
|
-
value: 'module',
|
|
87
|
-
selected: true
|
|
88
|
-
}, {
|
|
89
|
-
title: 'commonjs - for legacy setups (Node.js < 20)',
|
|
90
|
-
value: 'commonjs',
|
|
91
|
-
selected: false
|
|
92
|
-
}, {
|
|
93
|
-
title: 'typescript - declaration files for typechecking',
|
|
94
|
-
value: 'typescript',
|
|
95
|
-
selected: /\.tsx?$/.test(entryFile)
|
|
96
|
-
}],
|
|
97
|
-
validate: input => Boolean(input.length)
|
|
98
|
-
}];
|
|
99
|
-
if (entryFile.endsWith('.js') && FLOW_PRGAMA_REGEX.test(await _fsExtra.default.readFile(_path.default.join(root, source, entryFile), 'utf-8'))) {
|
|
100
|
-
questions.push({
|
|
101
|
-
type: 'confirm',
|
|
102
|
-
name: 'flow',
|
|
103
|
-
message: 'Do you want to publish definitions for flow?',
|
|
104
|
-
initial: Object.keys(pkg.devDependencies || {}).includes('flow-bin')
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
109
|
-
const {
|
|
110
|
-
output,
|
|
111
|
-
targets,
|
|
112
|
-
flow
|
|
113
|
-
} = await (0, _prompts.default)(questions);
|
|
114
|
-
const target = targets[0] === 'commonjs' || targets[0] === 'module' ? targets[0] : undefined;
|
|
115
|
-
const entries = {
|
|
116
|
-
source: `./${_path.default.join(source, entryFile)}`
|
|
117
|
-
};
|
|
118
|
-
let esm = false;
|
|
119
|
-
if (targets.includes('module')) {
|
|
120
|
-
esm = true;
|
|
121
|
-
entries.module = `./${_path.default.join(output, 'module', 'index.js')}`;
|
|
122
|
-
}
|
|
123
|
-
if (targets.includes('commonjs')) {
|
|
124
|
-
entries.commonjs = `./${_path.default.join(output, 'commonjs', 'index.js')}`;
|
|
125
|
-
}
|
|
126
|
-
const types = {};
|
|
127
|
-
if (targets.includes('typescript')) {
|
|
128
|
-
if (targets.includes('commonjs') && targets.includes('module')) {
|
|
129
|
-
types.require = `./${_path.default.join(output, 'typescript', 'commonjs', source, 'index.d.ts')}`;
|
|
130
|
-
types.import = `./${_path.default.join(output, 'typescript', 'module', source, 'index.d.ts')}`;
|
|
131
|
-
} else {
|
|
132
|
-
types.require = `./${_path.default.join(output, 'typescript', source, 'index.d.ts')}`;
|
|
133
|
-
types.import = types.require;
|
|
134
|
-
}
|
|
135
|
-
if (!(await _fsExtra.default.pathExists(_path.default.join(root, 'tsconfig.json')))) {
|
|
136
|
-
const {
|
|
137
|
-
tsconfig
|
|
138
|
-
} = await (0, _prompts.default)({
|
|
139
|
-
type: 'confirm',
|
|
140
|
-
name: 'tsconfig',
|
|
141
|
-
message: `You have enabled 'typescript' compilation, but we couldn't find a 'tsconfig.json' in project root.\n Generate one?`,
|
|
142
|
-
initial: true
|
|
143
|
-
});
|
|
144
|
-
if (tsconfig) {
|
|
145
|
-
await _fsExtra.default.writeJSON(_path.default.join(root, 'tsconfig.json'), {
|
|
146
|
-
compilerOptions: {
|
|
147
|
-
rootDir: '.',
|
|
148
|
-
allowUnreachableCode: false,
|
|
149
|
-
allowUnusedLabels: false,
|
|
150
|
-
esModuleInterop: true,
|
|
151
|
-
forceConsistentCasingInFileNames: true,
|
|
152
|
-
jsx: 'react-jsx',
|
|
153
|
-
lib: ['ESNext'],
|
|
154
|
-
module: 'ESNext',
|
|
155
|
-
moduleResolution: 'bundler',
|
|
156
|
-
noFallthroughCasesInSwitch: true,
|
|
157
|
-
noImplicitReturns: true,
|
|
158
|
-
noImplicitUseStrict: false,
|
|
159
|
-
noStrictGenericChecks: false,
|
|
160
|
-
noUncheckedIndexedAccess: true,
|
|
161
|
-
noUnusedLocals: true,
|
|
162
|
-
noUnusedParameters: true,
|
|
163
|
-
resolveJsonModule: true,
|
|
164
|
-
skipLibCheck: true,
|
|
165
|
-
strict: true,
|
|
166
|
-
target: 'ESNext',
|
|
167
|
-
verbatimModuleSyntax: true
|
|
168
|
-
}
|
|
169
|
-
}, {
|
|
170
|
-
spaces: 2
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
const prepare = 'bob build';
|
|
176
|
-
const files = [source, output, '!**/__tests__', '!**/__fixtures__', '!**/__mocks__'];
|
|
177
|
-
if (esm) {
|
|
178
|
-
let replace = false;
|
|
179
|
-
const exportsField = {
|
|
180
|
-
'.': {},
|
|
181
|
-
'./package.json': './package.json'
|
|
182
|
-
};
|
|
183
|
-
const importField = {
|
|
184
|
-
...(types.import ? {
|
|
185
|
-
types: types.import
|
|
186
|
-
} : null),
|
|
187
|
-
...(entries.module ? {
|
|
188
|
-
default: entries.module
|
|
189
|
-
} : null)
|
|
190
|
-
};
|
|
191
|
-
const requireField = {
|
|
192
|
-
...(types.require ? {
|
|
193
|
-
types: types.require
|
|
194
|
-
} : null),
|
|
195
|
-
...(entries.commonjs ? {
|
|
196
|
-
default: entries.commonjs
|
|
197
|
-
} : null)
|
|
198
|
-
};
|
|
199
|
-
if (targets.includes('commonjs') && targets.includes('module')) {
|
|
200
|
-
exportsField['.'] = {
|
|
201
|
-
source: entries.source,
|
|
202
|
-
import: importField,
|
|
203
|
-
require: requireField
|
|
204
|
-
};
|
|
205
|
-
} else if (targets.includes('commonjs')) {
|
|
206
|
-
exportsField['.'] = {
|
|
207
|
-
source: entries.source,
|
|
208
|
-
...requireField
|
|
209
|
-
};
|
|
210
|
-
} else if (targets.includes('module')) {
|
|
211
|
-
exportsField['.'] = {
|
|
212
|
-
source: entries.source,
|
|
213
|
-
...importField
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
if (pkg.exports && JSON.stringify(pkg.exports) !== JSON.stringify(exportsField)) {
|
|
217
|
-
replace = (await (0, _prompts.default)({
|
|
218
|
-
type: 'confirm',
|
|
219
|
-
name: 'replace',
|
|
220
|
-
message: `Your package.json has 'exports' field set.\n Do you want to replace it?`,
|
|
221
|
-
initial: true
|
|
222
|
-
})).replace;
|
|
223
|
-
} else {
|
|
224
|
-
replace = true;
|
|
225
|
-
}
|
|
226
|
-
if (replace) {
|
|
227
|
-
pkg.exports = exportsField;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
const entryFields = {};
|
|
231
|
-
if (targets.includes('commonjs') && targets.includes('module')) {
|
|
232
|
-
entryFields.main = entries.commonjs;
|
|
233
|
-
entryFields.module = entries.module;
|
|
234
|
-
if (targets.includes('typescript')) {
|
|
235
|
-
entryFields.types = types.require;
|
|
236
|
-
}
|
|
237
|
-
} else if (targets.includes('commonjs')) {
|
|
238
|
-
entryFields.main = entries.commonjs;
|
|
239
|
-
if (targets.includes('typescript')) {
|
|
240
|
-
entryFields.types = types.require;
|
|
241
|
-
}
|
|
242
|
-
} else if (targets.includes('module')) {
|
|
243
|
-
entryFields.main = entries.module;
|
|
244
|
-
if (targets.includes('typescript')) {
|
|
245
|
-
entryFields.types = types.import;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
for (const key in entryFields) {
|
|
249
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
250
|
-
const entry = entryFields[key];
|
|
251
|
-
if (pkg[key] && pkg[key] !== entry) {
|
|
252
|
-
const {
|
|
253
|
-
replace
|
|
254
|
-
} = await (0, _prompts.default)({
|
|
255
|
-
type: 'confirm',
|
|
256
|
-
name: 'replace',
|
|
257
|
-
message: `Your package.json has the '${key}' field set to '${String(pkg[key])}'.\n Do you want to replace it with '${String(entry)}'?`,
|
|
258
|
-
initial: true
|
|
259
|
-
});
|
|
260
|
-
if (replace) {
|
|
261
|
-
pkg[key] = entry;
|
|
262
|
-
}
|
|
263
|
-
} else {
|
|
264
|
-
pkg[key] = entry;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
if (pkg['react-native'] && (pkg['react-native'].startsWith(source) || pkg['react-native'].startsWith(`./${source}`))) {
|
|
268
|
-
const {
|
|
269
|
-
remove
|
|
270
|
-
} = await (0, _prompts.default)({
|
|
271
|
-
type: 'confirm',
|
|
272
|
-
name: 'remove',
|
|
273
|
-
message: `Your package.json has the 'react-native' field pointing to source code.\n This can cause problems when customizing babel configuration.\n Do you want to remove it?`,
|
|
274
|
-
initial: true
|
|
275
|
-
});
|
|
276
|
-
if (remove) {
|
|
277
|
-
delete pkg['react-native'];
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
if (pkg.scripts?.prepare && pkg.scripts.prepare !== prepare) {
|
|
281
|
-
const {
|
|
282
|
-
replace
|
|
283
|
-
} = await (0, _prompts.default)({
|
|
284
|
-
type: 'confirm',
|
|
285
|
-
name: 'replace',
|
|
286
|
-
message: `Your package.json has the 'scripts.prepare' field set to '${String(pkg.scripts.prepare)}'.\n Do you want to replace it with '${prepare}'?`,
|
|
287
|
-
initial: true
|
|
288
|
-
});
|
|
289
|
-
if (replace) {
|
|
290
|
-
pkg.scripts.prepare = prepare;
|
|
291
|
-
}
|
|
292
|
-
} else {
|
|
293
|
-
pkg.scripts = pkg.scripts || {};
|
|
294
|
-
pkg.scripts.prepare = prepare;
|
|
295
|
-
}
|
|
296
|
-
if (pkg.files) {
|
|
297
|
-
const pkgFiles = pkg.files;
|
|
298
|
-
if (files?.some(file => !pkgFiles.includes(file))) {
|
|
299
|
-
const {
|
|
300
|
-
update
|
|
301
|
-
} = await (0, _prompts.default)({
|
|
302
|
-
type: 'confirm',
|
|
303
|
-
name: 'update',
|
|
304
|
-
message: `Your package.json already has a 'files' field.\n Do you want to update it?`,
|
|
305
|
-
initial: true
|
|
306
|
-
});
|
|
307
|
-
if (update) {
|
|
308
|
-
pkg.files = [...files, ...pkg.files.filter(file => !files.includes(file))];
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
} else {
|
|
312
|
-
pkg.files = files;
|
|
313
|
-
}
|
|
314
|
-
pkg[_package.default.name] = {
|
|
315
|
-
source,
|
|
316
|
-
output,
|
|
317
|
-
targets: targets.map(t => {
|
|
318
|
-
if (t === target && flow) {
|
|
319
|
-
return [t, {
|
|
320
|
-
copyFlow: true
|
|
321
|
-
}];
|
|
322
|
-
}
|
|
323
|
-
if (t === 'commonjs' || t === 'module') {
|
|
324
|
-
return [t, {
|
|
325
|
-
esm
|
|
326
|
-
}];
|
|
327
|
-
}
|
|
328
|
-
return t;
|
|
329
|
-
})
|
|
330
|
-
};
|
|
331
|
-
if (pkg.jest) {
|
|
332
|
-
const entry = `<rootDir>/${output}/`;
|
|
333
|
-
if (pkg.jest.modulePathIgnorePatterns) {
|
|
334
|
-
const {
|
|
335
|
-
modulePathIgnorePatterns
|
|
336
|
-
} = pkg.jest;
|
|
337
|
-
if (!modulePathIgnorePatterns.includes(entry)) {
|
|
338
|
-
modulePathIgnorePatterns.push(entry);
|
|
339
|
-
}
|
|
340
|
-
} else {
|
|
341
|
-
pkg.jest.modulePathIgnorePatterns = [entry];
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
pkg.eslintIgnore = pkg.eslintIgnore || ['node_modules/'];
|
|
345
|
-
if (!pkg.eslintIgnore.includes(`${output}/`)) {
|
|
346
|
-
pkg.eslintIgnore.push(`${output}/`);
|
|
347
|
-
}
|
|
348
|
-
await _fsExtra.default.writeJSON(projectPackagePath, pkg, {
|
|
349
|
-
spaces: 2
|
|
350
|
-
});
|
|
351
|
-
const ignorefiles = [_path.default.join(root, '.gitignore'), _path.default.join(root, '.eslintignore')];
|
|
352
|
-
for (const ignorefile of ignorefiles) {
|
|
353
|
-
if (await _fsExtra.default.pathExists(ignorefile)) {
|
|
354
|
-
const content = await _fsExtra.default.readFile(ignorefile, 'utf-8');
|
|
355
|
-
if (!content.split('\n').includes(`${output}/`)) {
|
|
356
|
-
await _fsExtra.default.writeFile(ignorefile, `${content}\n# generated by bob\n${output}/\n`);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
const packageManager = (await _fsExtra.default.pathExists(_path.default.join(root, 'yarn.lock'))) ? 'yarn' : 'npm';
|
|
361
|
-
process.stdout.write((0, _dedent.default)(`
|
|
362
|
-
Project ${_kleur.default.yellow(pkg.name)} configured successfully!
|
|
363
|
-
|
|
364
|
-
${_kleur.default.magenta(`${_kleur.default.bold('Perform last steps')} by running`)}${_kleur.default.gray(':')}
|
|
365
|
-
|
|
366
|
-
${_kleur.default.gray('$')} ${packageManager} install
|
|
367
|
-
|
|
368
|
-
${_kleur.default.yellow('Good luck!')}
|
|
369
|
-
`));
|
|
370
|
-
}
|
|
371
|
-
//# sourceMappingURL=init.js.map
|
package/lib/init.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","names":["_path","_interopRequireDefault","require","_fsExtra","_kleur","_dedent","_isGitDirty","_prompts","_loadConfig","_package","e","__esModule","default","FLOW_PRGAMA_REGEX","init","root","process","cwd","projectPackagePath","path","resolve","isGitDirty","shouldContinue","prompts","type","name","message","initial","exit","fs","pathExists","Error","pkg","JSON","parse","readFile","result","loadConfig","config","devDependencies","pack","source","validate","input","Boolean","entryFile","join","Object","fromEntries","entries","version","sort","a","b","localeCompare","questions","choices","title","value","selected","test","length","endsWith","push","keys","includes","output","targets","flow","target","undefined","esm","module","commonjs","types","import","tsconfig","writeJSON","compilerOptions","rootDir","allowUnreachableCode","allowUnusedLabels","esModuleInterop","forceConsistentCasingInFileNames","jsx","lib","moduleResolution","noFallthroughCasesInSwitch","noImplicitReturns","noImplicitUseStrict","noStrictGenericChecks","noUncheckedIndexedAccess","noUnusedLocals","noUnusedParameters","resolveJsonModule","skipLibCheck","strict","verbatimModuleSyntax","spaces","prepare","files","replace","exportsField","importField","requireField","exports","stringify","entryFields","main","key","entry","String","startsWith","remove","scripts","pkgFiles","some","file","update","filter","map","t","copyFlow","jest","modulePathIgnorePatterns","eslintIgnore","ignorefiles","ignorefile","content","split","writeFile","packageManager","stdout","write","dedent","kleur","yellow","magenta","bold","gray"],"sources":["../src/init.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs-extra';\nimport kleur from 'kleur';\nimport dedent from 'dedent';\nimport isGitDirty from 'is-git-dirty';\nimport prompts, { type PromptObject } from './utils/prompts';\nimport { loadConfig } from './utils/loadConfig';\nimport pack from '../package.json';\n\nconst FLOW_PRGAMA_REGEX = /\\*?\\s*@(flow)\\b/m;\n\nexport async function init() {\n const root = process.cwd();\n const projectPackagePath = path.resolve(root, 'package.json');\n\n if (isGitDirty()) {\n const { shouldContinue } = await prompts({\n type: 'confirm',\n name: 'shouldContinue',\n message: `The working directory is not clean.\\n You should commit or stash your changes before configuring bob.\\n Continue anyway?`,\n initial: false,\n });\n\n if (!shouldContinue) {\n process.exit(0);\n }\n }\n\n if (!(await fs.pathExists(projectPackagePath))) {\n throw new Error(\n `Couldn't find a 'package.json' file in '${root}'.\\n Are you in a project folder?`\n );\n }\n\n const pkg = JSON.parse(await fs.readFile(projectPackagePath, 'utf-8'));\n const result = loadConfig(root);\n\n if (\n result?.config &&\n pkg.devDependencies &&\n pack.name in pkg.devDependencies\n ) {\n const { shouldContinue } = await prompts({\n type: 'confirm',\n name: 'shouldContinue',\n message: `The project seems to be already configured with bob.\\n Do you want to overwrite the existing configuration?`,\n initial: false,\n });\n\n if (!shouldContinue) {\n process.exit(0);\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion\n const { source } = (await prompts({\n type: 'text',\n name: 'source',\n message: 'Where are your source files?',\n initial: 'src',\n validate: (input) => Boolean(input),\n })) as { source: string };\n\n let entryFile;\n\n if (await fs.pathExists(path.join(root, source, 'index.js'))) {\n entryFile = 'index.js';\n } else if (await fs.pathExists(path.join(root, source, 'index.ts'))) {\n entryFile = 'index.ts';\n } else if (await fs.pathExists(path.join(root, source, 'index.tsx'))) {\n entryFile = 'index.tsx';\n }\n\n if (!entryFile) {\n throw new Error(\n `Couldn't find a 'index.js'. 'index.ts' or 'index.tsx' file under '${source}'.\\n Please re-run the CLI after creating it.`\n );\n }\n\n pkg.devDependencies = Object.fromEntries(\n [\n ...Object.entries(pkg.devDependencies || {}),\n [pack.name, `^${pack.version}`],\n ].sort(([a], [b]) => a.localeCompare(b))\n );\n\n const questions: PromptObject[] = [\n {\n type: 'text',\n name: 'output',\n message: 'Where do you want to generate the output files?',\n initial: 'lib',\n validate: (input: string) => Boolean(input),\n },\n {\n type: 'multiselect',\n name: 'targets',\n message: 'Which targets do you want to build?',\n choices: [\n {\n title: 'module - for modern setups',\n value: 'module',\n selected: true,\n },\n {\n title: 'commonjs - for legacy setups (Node.js < 20)',\n value: 'commonjs',\n selected: false,\n },\n {\n title: 'typescript - declaration files for typechecking',\n value: 'typescript',\n selected: /\\.tsx?$/.test(entryFile),\n },\n ],\n validate: (input: string) => Boolean(input.length),\n },\n ];\n\n if (\n entryFile.endsWith('.js') &&\n FLOW_PRGAMA_REGEX.test(\n await fs.readFile(path.join(root, source, entryFile), 'utf-8')\n )\n ) {\n questions.push({\n type: 'confirm',\n name: 'flow',\n message: 'Do you want to publish definitions for flow?',\n initial: Object.keys(pkg.devDependencies || {}).includes('flow-bin'),\n });\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion\n const { output, targets, flow } = (await prompts(questions)) as {\n output: string;\n targets: string[];\n flow?: boolean;\n };\n\n const target =\n targets[0] === 'commonjs' || targets[0] === 'module'\n ? targets[0]\n : undefined;\n\n const entries: {\n [key in 'source' | 'commonjs' | 'module']?: string;\n } = {\n source: `./${path.join(source, entryFile)}`,\n };\n\n let esm = false;\n\n if (targets.includes('module')) {\n esm = true;\n entries.module = `./${path.join(output, 'module', 'index.js')}`;\n }\n\n if (targets.includes('commonjs')) {\n entries.commonjs = `./${path.join(output, 'commonjs', 'index.js')}`;\n }\n\n const types: {\n [key in 'require' | 'import']?: string;\n } = {};\n\n if (targets.includes('typescript')) {\n if (targets.includes('commonjs') && targets.includes('module')) {\n types.require = `./${path.join(\n output,\n 'typescript',\n 'commonjs',\n source,\n 'index.d.ts'\n )}`;\n\n types.import = `./${path.join(\n output,\n 'typescript',\n 'module',\n source,\n 'index.d.ts'\n )}`;\n } else {\n types.require = `./${path.join(\n output,\n 'typescript',\n source,\n 'index.d.ts'\n )}`;\n\n types.import = types.require;\n }\n\n if (!(await fs.pathExists(path.join(root, 'tsconfig.json')))) {\n const { tsconfig } = await prompts({\n type: 'confirm',\n name: 'tsconfig',\n message: `You have enabled 'typescript' compilation, but we couldn't find a 'tsconfig.json' in project root.\\n Generate one?`,\n initial: true,\n });\n\n if (tsconfig) {\n await fs.writeJSON(\n path.join(root, 'tsconfig.json'),\n {\n compilerOptions: {\n rootDir: '.',\n allowUnreachableCode: false,\n allowUnusedLabels: false,\n esModuleInterop: true,\n forceConsistentCasingInFileNames: true,\n jsx: 'react-jsx',\n lib: ['ESNext'],\n module: 'ESNext',\n moduleResolution: 'bundler',\n noFallthroughCasesInSwitch: true,\n noImplicitReturns: true,\n noImplicitUseStrict: false,\n noStrictGenericChecks: false,\n noUncheckedIndexedAccess: true,\n noUnusedLocals: true,\n noUnusedParameters: true,\n resolveJsonModule: true,\n skipLibCheck: true,\n strict: true,\n target: 'ESNext',\n verbatimModuleSyntax: true,\n },\n },\n { spaces: 2 }\n );\n }\n }\n }\n\n const prepare = 'bob build';\n const files = [\n source,\n output,\n '!**/__tests__',\n '!**/__fixtures__',\n '!**/__mocks__',\n ];\n\n if (esm) {\n let replace = false;\n\n const exportsField = {\n '.': {},\n './package.json': './package.json',\n };\n\n const importField = {\n ...(types.import ? { types: types.import } : null),\n ...(entries.module ? { default: entries.module } : null),\n };\n\n const requireField = {\n ...(types.require ? { types: types.require } : null),\n ...(entries.commonjs ? { default: entries.commonjs } : null),\n };\n\n if (targets.includes('commonjs') && targets.includes('module')) {\n exportsField['.'] = {\n source: entries.source,\n import: importField,\n require: requireField,\n };\n } else if (targets.includes('commonjs')) {\n exportsField['.'] = {\n source: entries.source,\n ...requireField,\n };\n } else if (targets.includes('module')) {\n exportsField['.'] = {\n source: entries.source,\n ...importField,\n };\n }\n\n if (\n pkg.exports &&\n JSON.stringify(pkg.exports) !== JSON.stringify(exportsField)\n ) {\n replace = (\n await prompts({\n type: 'confirm',\n name: 'replace',\n message: `Your package.json has 'exports' field set.\\n Do you want to replace it?`,\n initial: true,\n })\n ).replace;\n } else {\n replace = true;\n }\n\n if (replace) {\n pkg.exports = exportsField;\n }\n }\n\n const entryFields: {\n [key in 'main' | 'module' | 'types']?: string;\n } = {};\n\n if (targets.includes('commonjs') && targets.includes('module')) {\n entryFields.main = entries.commonjs;\n entryFields.module = entries.module;\n\n if (targets.includes('typescript')) {\n entryFields.types = types.require;\n }\n } else if (targets.includes('commonjs')) {\n entryFields.main = entries.commonjs;\n\n if (targets.includes('typescript')) {\n entryFields.types = types.require;\n }\n } else if (targets.includes('module')) {\n entryFields.main = entries.module;\n\n if (targets.includes('typescript')) {\n entryFields.types = types.import;\n }\n }\n\n for (const key in entryFields) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion\n const entry = entryFields[key as keyof typeof entryFields];\n\n if (pkg[key] && pkg[key] !== entry) {\n const { replace } = await prompts({\n type: 'confirm',\n name: 'replace',\n message: `Your package.json has the '${key}' field set to '${String(pkg[key])}'.\\n Do you want to replace it with '${String(entry)}'?`,\n initial: true,\n });\n\n if (replace) {\n pkg[key] = entry;\n }\n } else {\n pkg[key] = entry;\n }\n }\n\n if (\n pkg['react-native'] &&\n (pkg['react-native'].startsWith(source) ||\n pkg['react-native'].startsWith(`./${source}`))\n ) {\n const { remove } = await prompts({\n type: 'confirm',\n name: 'remove',\n message: `Your package.json has the 'react-native' field pointing to source code.\\n This can cause problems when customizing babel configuration.\\n Do you want to remove it?`,\n initial: true,\n });\n\n if (remove) {\n delete pkg['react-native'];\n }\n }\n\n if (pkg.scripts?.prepare && pkg.scripts.prepare !== prepare) {\n const { replace } = await prompts({\n type: 'confirm',\n name: 'replace',\n message: `Your package.json has the 'scripts.prepare' field set to '${String(pkg.scripts.prepare)}'.\\n Do you want to replace it with '${prepare}'?`,\n initial: true,\n });\n\n if (replace) {\n pkg.scripts.prepare = prepare;\n }\n } else {\n pkg.scripts = pkg.scripts || {};\n pkg.scripts.prepare = prepare;\n }\n\n if (pkg.files) {\n const pkgFiles = pkg.files;\n\n if (files?.some((file) => !pkgFiles.includes(file))) {\n const { update } = await prompts({\n type: 'confirm',\n name: 'update',\n message: `Your package.json already has a 'files' field.\\n Do you want to update it?`,\n initial: true,\n });\n\n if (update) {\n pkg.files = [\n ...files,\n ...pkg.files.filter((file: string) => !files.includes(file)),\n ];\n }\n }\n } else {\n pkg.files = files;\n }\n\n pkg[pack.name] = {\n source,\n output,\n targets: targets.map((t: string) => {\n if (t === target && flow) {\n return [t, { copyFlow: true }];\n }\n\n if (t === 'commonjs' || t === 'module') {\n return [t, { esm }];\n }\n\n return t;\n }),\n };\n\n if (pkg.jest) {\n const entry = `<rootDir>/${output}/`;\n\n if (pkg.jest.modulePathIgnorePatterns) {\n const { modulePathIgnorePatterns } = pkg.jest;\n\n if (!modulePathIgnorePatterns.includes(entry)) {\n modulePathIgnorePatterns.push(entry);\n }\n } else {\n pkg.jest.modulePathIgnorePatterns = [entry];\n }\n }\n\n pkg.eslintIgnore = pkg.eslintIgnore || ['node_modules/'];\n\n if (!pkg.eslintIgnore.includes(`${output}/`)) {\n pkg.eslintIgnore.push(`${output}/`);\n }\n\n await fs.writeJSON(projectPackagePath, pkg, {\n spaces: 2,\n });\n\n const ignorefiles = [\n path.join(root, '.gitignore'),\n path.join(root, '.eslintignore'),\n ];\n\n for (const ignorefile of ignorefiles) {\n if (await fs.pathExists(ignorefile)) {\n const content = await fs.readFile(ignorefile, 'utf-8');\n\n if (!content.split('\\n').includes(`${output}/`)) {\n await fs.writeFile(\n ignorefile,\n `${content}\\n# generated by bob\\n${output}/\\n`\n );\n }\n }\n }\n\n const packageManager = (await fs.pathExists(path.join(root, 'yarn.lock')))\n ? 'yarn'\n : 'npm';\n\n process.stdout.write(\n dedent(`\n Project ${kleur.yellow(pkg.name)} configured successfully!\n\n ${kleur.magenta(\n `${kleur.bold('Perform last steps')} by running`\n )}${kleur.gray(':')}\n\n ${kleur.gray('$')} ${packageManager} install\n\n ${kleur.yellow('Good luck!')}\n `)\n );\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,MAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,OAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,WAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,QAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAR,sBAAA,CAAAC,OAAA;AAAmC,SAAAD,uBAAAS,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEnC,MAAMG,iBAAiB,GAAG,kBAAkB;AAErC,eAAeC,IAAIA,CAAA,EAAG;EAC3B,MAAMC,IAAI,GAAGC,OAAO,CAACC,GAAG,CAAC,CAAC;EAC1B,MAAMC,kBAAkB,GAAGC,aAAI,CAACC,OAAO,CAACL,IAAI,EAAE,cAAc,CAAC;EAE7D,IAAI,IAAAM,mBAAU,EAAC,CAAC,EAAE;IAChB,MAAM;MAAEC;IAAe,CAAC,GAAG,MAAM,IAAAC,gBAAO,EAAC;MACvCC,IAAI,EAAE,SAAS;MACfC,IAAI,EAAE,gBAAgB;MACtBC,OAAO,EAAE,4HAA4H;MACrIC,OAAO,EAAE;IACX,CAAC,CAAC;IAEF,IAAI,CAACL,cAAc,EAAE;MACnBN,OAAO,CAACY,IAAI,CAAC,CAAC,CAAC;IACjB;EACF;EAEA,IAAI,EAAE,MAAMC,gBAAE,CAACC,UAAU,CAACZ,kBAAkB,CAAC,CAAC,EAAE;IAC9C,MA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AAE,CAACC,UAAU,CAACX,aAAI,CAAC2B,IAAI,CAAC/B,IAAI,EAAE,WAAW,CAAC,CAAC,IACrE,MAAM,GACN,KAAK;EAETC,OAAO,CAACoH,MAAM,CAACC,KAAK,CAClB,IAAAC,eAAM,EAAC;AACX,cAAcC,cAAK,CAACC,MAAM,CAACxG,GAAG,CAACP,IAAI,CAAC;AACpC;AACA,MAAM8G,cAAK,CAACE,OAAO,CACb,GAAGF,cAAK,CAACG,IAAI,CAAC,oBAAoB,CAAC,aACrC,CAAC,GAAGH,cAAK,CAACI,IAAI,CAAC,GAAG,CAAC;AACvB;AACA,QAAQJ,cAAK,CAACI,IAAI,CAAC,GAAG,CAAC,IAAIR,cAAc;AACzC;AACA,MAAMI,cAAK,CAACC,MAAM,CAAC,YAAY,CAAC;AAChC,GAAG,CACD,CAAC;AACH","ignoreList":[]}
|
package/lib/schema.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.config = void 0;
|
|
7
|
-
var _arktype = require("arktype");
|
|
8
|
-
const _module = {
|
|
9
|
-
name: '"module"',
|
|
10
|
-
options: (0, _arktype.type)({
|
|
11
|
-
esm: (0, _arktype.type)('boolean').default(false),
|
|
12
|
-
babelrc: (0, _arktype.type)('boolean').default(false),
|
|
13
|
-
configFile: (0, _arktype.type)('boolean | string').default(false),
|
|
14
|
-
sourceMaps: (0, _arktype.type)('boolean').default(true),
|
|
15
|
-
copyFlow: (0, _arktype.type)('boolean').default(false),
|
|
16
|
-
jsxRuntime: (0, _arktype.type)('"automatic" | "classic"').default('automatic')
|
|
17
|
-
})
|
|
18
|
-
};
|
|
19
|
-
const commonjs = {
|
|
20
|
-
name: '"commonjs"',
|
|
21
|
-
options: _module.options
|
|
22
|
-
};
|
|
23
|
-
const typescript = {
|
|
24
|
-
name: '"typescript"',
|
|
25
|
-
options: (0, _arktype.type)({
|
|
26
|
-
project: 'string?',
|
|
27
|
-
tsc: 'string?'
|
|
28
|
-
})
|
|
29
|
-
};
|
|
30
|
-
const codegen = {
|
|
31
|
-
name: '"codegen"'
|
|
32
|
-
};
|
|
33
|
-
const custom = {
|
|
34
|
-
name: '"custom"',
|
|
35
|
-
options: (0, _arktype.type)({
|
|
36
|
-
script: 'string',
|
|
37
|
-
clean: 'string?'
|
|
38
|
-
})
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
42
|
-
const target = _arktype.type.or(commonjs.name, _module.name, typescript.name, codegen.name, custom.name);
|
|
43
|
-
const config = exports.config = (0, _arktype.type)({
|
|
44
|
-
source: 'string',
|
|
45
|
-
output: 'string',
|
|
46
|
-
targets: _arktype.type.or(_arktype.type.or(_module.name, [_module.name], [_module.name, _module.options]), _arktype.type.or(commonjs.name, [commonjs.name], [commonjs.name, commonjs.options]), _arktype.type.or(typescript.name, [typescript.name], [typescript.name, typescript.options]), _arktype.type.or(codegen.name, [codegen.name]), [custom.name, custom.options]).array().moreThanLength(0),
|
|
47
|
-
exclude: _arktype.type.string.default('**/{__tests__,__fixtures__,__mocks__}/**')
|
|
48
|
-
}).onDeepUndeclaredKey('reject');
|
|
49
|
-
//# sourceMappingURL=schema.js.map
|
package/lib/schema.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","names":["_arktype","require","module","name","options","type","esm","default","babelrc","configFile","sourceMaps","copyFlow","jsxRuntime","commonjs","typescript","project","tsc","codegen","custom","script","clean","target","or","config","exports","source","output","targets","array","moreThanLength","exclude","string","onDeepUndeclaredKey"],"sources":["../src/schema.ts"],"sourcesContent":["import { type } from 'arktype';\n\nconst module = {\n name: '\"module\"',\n options: type({\n esm: type('boolean').default(false),\n babelrc: type('boolean').default(false),\n configFile: type('boolean | string').default(false),\n sourceMaps: type('boolean').default(true),\n copyFlow: type('boolean').default(false),\n jsxRuntime: type('\"automatic\" | \"classic\"').default('automatic'),\n }),\n} as const;\n\nconst commonjs = {\n name: '\"commonjs\"',\n options: module.options,\n} as const;\n\nconst typescript = {\n name: '\"typescript\"',\n options: type({\n project: 'string?',\n tsc: 'string?',\n }),\n} as const;\n\nconst codegen = {\n name: '\"codegen\"',\n} as const;\n\nconst custom = {\n name: '\"custom\"',\n options: type({\n script: 'string',\n clean: 'string?',\n }),\n} as const;\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nconst target = type.or(\n commonjs.name,\n module.name,\n typescript.name,\n codegen.name,\n custom.name\n);\n\nexport const config = type({\n source: 'string',\n output: 'string',\n targets: type\n .or(\n type.or(module.name, [module.name], [module.name, module.options]),\n type.or(\n commonjs.name,\n [commonjs.name],\n [commonjs.name, commonjs.options]\n ),\n type.or(\n typescript.name,\n [typescript.name],\n [typescript.name, typescript.options]\n ),\n type.or(codegen.name, [codegen.name]),\n [custom.name, custom.options]\n )\n .array()\n .moreThanLength(0),\n exclude: type.string.default('**/{__tests__,__fixtures__,__mocks__}/**'),\n}).onDeepUndeclaredKey('reject');\n\nexport type Config = typeof config.infer;\n\nexport type Target = typeof target.infer;\n\nexport type TargetOptions<T extends Target> = T extends typeof commonjs.name\n ? typeof commonjs.options.infer\n : T extends typeof module.name\n ? typeof module.options.infer\n : T extends typeof typescript.name\n ? typeof typescript.options.infer\n : T extends typeof custom.name\n ? typeof custom.options.infer\n : T extends typeof codegen.name\n ? undefined\n : never;\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAEA,MAAMC,OAAM,GAAG;EACbC,IAAI,EAAE,UAAU;EAChBC,OAAO,EAAE,IAAAC,aAAI,EAAC;IACZC,GAAG,EAAE,IAAAD,aAAI,EAAC,SAAS,CAAC,CAACE,OAAO,CAAC,KAAK,CAAC;IACnCC,OAAO,EAAE,IAAAH,aAAI,EAAC,SAAS,CAAC,CAACE,OAAO,CAAC,KAAK,CAAC;IACvCE,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EAAE,CAACD,OAAM,CAACC,IAAI,EAAED,OAAM,CAACE,OAAO,CAAC,CAAC,EAClEC,aAAI,CAACiB,EAAE,CACLT,QAAQ,CAACV,IAAI,EACb,CAACU,QAAQ,CAACV,IAAI,CAAC,EACf,CAACU,QAAQ,CAACV,IAAI,EAAEU,QAAQ,CAACT,OAAO,CAClC,CAAC,EACDC,aAAI,CAACiB,EAAE,CACLR,UAAU,CAACX,IAAI,EACf,CAACW,UAAU,CAACX,IAAI,CAAC,EACjB,CAACW,UAAU,CAACX,IAAI,EAAEW,UAAU,CAACV,OAAO,CACtC,CAAC,EACDC,aAAI,CAACiB,EAAE,CAACL,OAAO,CAACd,IAAI,EAAE,CAACc,OAAO,CAACd,IAAI,CAAC,CAAC,EACrC,CAACe,MAAM,CAACf,IAAI,EAAEe,MAAM,CAACd,OAAO,CAC9B,CAAC,CACAwB,KAAK,CAAC,CAAC,CACPC,cAAc,CAAC,CAAC,CAAC;EACpBC,OAAO,EAAEzB,aAAI,CAAC0B,MAAM,CAACxB,OAAO,CAAC,0CAA0C;AACzE,CAAC,CAAC,CAACyB,mBAAmB,CAAC,QAAQ,CAAC","ignoreList":[]}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = build;
|
|
7
|
-
var _kleur = _interopRequireDefault(require("kleur"));
|
|
8
|
-
var _patchCodegenAndroidPackage = require("./patches/patchCodegenAndroidPackage");
|
|
9
|
-
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
10
|
-
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
var _del = require("del");
|
|
12
|
-
var _removeCodegenAppLevelCode = require("./patches/removeCodegenAppLevelCode");
|
|
13
|
-
var _spawn = require("../../utils/spawn");
|
|
14
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
-
async function build({
|
|
16
|
-
root,
|
|
17
|
-
report
|
|
18
|
-
}) {
|
|
19
|
-
const packageJsonPath = _path.default.resolve(root, 'package.json');
|
|
20
|
-
const packageJson = await _fsExtra.default.readJson(packageJsonPath);
|
|
21
|
-
const codegenIosPath = packageJson.codegenConfig?.outputDir?.ios;
|
|
22
|
-
if (codegenIosPath != null) {
|
|
23
|
-
report.info(`Cleaning up previous iOS codegen native code at ${_kleur.default.blue(_path.default.relative(root, codegenIosPath))}`);
|
|
24
|
-
await (0, _del.deleteAsync)([codegenIosPath]);
|
|
25
|
-
}
|
|
26
|
-
const codegenAndroidPath = packageJson.codegenConfig?.outputDir?.android;
|
|
27
|
-
if (codegenAndroidPath != null) {
|
|
28
|
-
report.info(`Cleaning up previous Android codegen native code at ${_kleur.default.blue(_path.default.relative(root, codegenAndroidPath))}`);
|
|
29
|
-
await (0, _del.deleteAsync)([codegenAndroidPath]);
|
|
30
|
-
}
|
|
31
|
-
const codegenType = packageJson.codegenConfig?.type;
|
|
32
|
-
if (codegenType === undefined) {
|
|
33
|
-
throw new Error("Couldn't find the 'type' value in 'codegenConfig'. Please check your package.json's 'codegenConfig' property and make sure 'type' is defined. https://reactnative.dev/docs/the-new-architecture/using-codegen#configuring-codegen");
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
const codegenCLISupportsSource = await (0, _removeCodegenAppLevelCode.getCodegenCLISourceSupport)();
|
|
37
|
-
await (0, _spawn.spawn)('npx', ['@react-native-community/cli', 'codegen', ...(codegenCLISupportsSource ? ['--source', 'library'] : [])]);
|
|
38
|
-
if (codegenType === 'modules' || codegenType === 'all') {
|
|
39
|
-
await (0, _patchCodegenAndroidPackage.patchCodegenAndroidPackage)(root, packageJson, report);
|
|
40
|
-
}
|
|
41
|
-
if (!codegenCLISupportsSource) {
|
|
42
|
-
await (0, _removeCodegenAppLevelCode.removeCodegenAppLevelCode)(root, packageJson);
|
|
43
|
-
}
|
|
44
|
-
report.success('Generated native code with codegen');
|
|
45
|
-
} catch (e) {
|
|
46
|
-
if (e != null && typeof e === 'object') {
|
|
47
|
-
if ('stdout' in e && e.stdout != null) {
|
|
48
|
-
report.error(`Errors found while running codegen:\n\n${e.stdout.toString()}`);
|
|
49
|
-
} else if ('message' in e && typeof e.message === 'string') {
|
|
50
|
-
if (e.message.includes("Error: Cannot find module '@react-native-community/cli/package.json'")) {
|
|
51
|
-
report.error("You don't have `@react-native-community/cli` in your root package's dev dependencies. Please install it and make sure it uses the same version as your application.");
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
throw new Error('Failed to run codegen.', {
|
|
56
|
-
cause: e
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_kleur","_interopRequireDefault","require","_patchCodegenAndroidPackage","_fsExtra","_path","_del","_removeCodegenAppLevelCode","_spawn","e","__esModule","default","build","root","report","packageJsonPath","path","resolve","packageJson","fs","readJson","codegenIosPath","codegenConfig","outputDir","ios","info","kleur","blue","relative","deleteAsync","codegenAndroidPath","android","codegenType","type","undefined","Error","codegenCLISupportsSource","getCodegenCLISourceSupport","spawn","patchCodegenAndroidPackage","removeCodegenAppLevelCode","success","stdout","error","toString","message","includes","cause"],"sources":["../../../src/targets/codegen/index.ts"],"sourcesContent":["import kleur from 'kleur';\nimport type { Input } from '../../types';\nimport { patchCodegenAndroidPackage } from './patches/patchCodegenAndroidPackage';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport { deleteAsync } from 'del';\nimport {\n getCodegenCLISourceSupport,\n removeCodegenAppLevelCode,\n} from './patches/removeCodegenAppLevelCode';\nimport { spawn } from '../../utils/spawn';\n\ntype Options = Omit<Input, 'output'>;\n\nexport default async function build({ root, report }: Options) {\n const packageJsonPath = path.resolve(root, 'package.json');\n const packageJson = await fs.readJson(packageJsonPath);\n\n const codegenIosPath = packageJson.codegenConfig?.outputDir?.ios;\n if (codegenIosPath != null) {\n report.info(\n `Cleaning up previous iOS codegen native code at ${kleur.blue(\n path.relative(root, codegenIosPath)\n )}`\n );\n await deleteAsync([codegenIosPath]);\n }\n\n const codegenAndroidPath = packageJson.codegenConfig?.outputDir?.android;\n if (codegenAndroidPath != null) {\n report.info(\n `Cleaning up previous Android codegen native code at ${kleur.blue(\n path.relative(root, codegenAndroidPath)\n )}`\n );\n await deleteAsync([codegenAndroidPath]);\n }\n\n const codegenType = packageJson.codegenConfig?.type;\n\n if (codegenType === undefined) {\n throw new Error(\n \"Couldn't find the 'type' value in 'codegenConfig'. Please check your package.json's 'codegenConfig' property and make sure 'type' is defined. https://reactnative.dev/docs/the-new-architecture/using-codegen#configuring-codegen\"\n );\n }\n\n try {\n const codegenCLISupportsSource = await getCodegenCLISourceSupport();\n\n await spawn('npx', [\n '@react-native-community/cli',\n 'codegen',\n ...(codegenCLISupportsSource ? ['--source', 'library'] : []),\n ]);\n\n if (codegenType === 'modules' || codegenType === 'all') {\n await patchCodegenAndroidPackage(root, packageJson, report);\n }\n\n if (!codegenCLISupportsSource) {\n await removeCodegenAppLevelCode(root, packageJson);\n }\n\n report.success('Generated native code with codegen');\n } catch (e: unknown) {\n if (e != null && typeof e === 'object') {\n if ('stdout' in e && e.stdout != null) {\n report.error(\n `Errors found while running codegen:\\n\\n${e.stdout.toString()}`\n );\n } else if ('message' in e && typeof e.message === 'string') {\n if (\n e.message.includes(\n \"Error: Cannot find module '@react-native-community/cli/package.json'\"\n )\n ) {\n report.error(\n \"You don't have `@react-native-community/cli` in your root package's dev dependencies. Please install it and make sure it uses the same version as your application.\"\n );\n }\n }\n }\n\n throw new Error('Failed to run codegen.', { cause: e });\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,2BAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,KA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", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CODEGEN_DOCS = void 0;
|
|
7
|
-
exports.patchCodegenAndroidPackage = patchCodegenAndroidPackage;
|
|
8
|
-
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
9
|
-
var _path = _interopRequireDefault(require("path"));
|
|
10
|
-
var _kleur = _interopRequireDefault(require("kleur"));
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
const CODEGEN_DOCS = exports.CODEGEN_DOCS = 'https://reactnative.dev/docs/the-new-architecture/using-codegen#configuring-codegen';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Currently, running react-native codegen generates java files with package name `com.facebook.fbreact.specs`.
|
|
16
|
-
* This is a known issue in react-native itself.
|
|
17
|
-
* 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.
|
|
18
|
-
* To workaround, this function renames the package name to the one provided in the codegenConfig.
|
|
19
|
-
* @throws if codegenConfig.outputDir.android or codegenConfig.android.javaPackageName is not defined in package.json
|
|
20
|
-
* @throws if the codegenAndroidPath does not exist
|
|
21
|
-
*/
|
|
22
|
-
async function patchCodegenAndroidPackage(projectPath,
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
-
packageJson, report) {
|
|
25
|
-
let codegenAndroidPath = packageJson.codegenConfig?.outputDir?.android;
|
|
26
|
-
if (!codegenAndroidPath) {
|
|
27
|
-
throw new Error(`Your package.json doesn't contain codegenConfig.outputDir.android. Please see ${CODEGEN_DOCS}`);
|
|
28
|
-
}
|
|
29
|
-
codegenAndroidPath = _path.default.resolve(projectPath, codegenAndroidPath);
|
|
30
|
-
if (!(await _fsExtra.default.pathExists(codegenAndroidPath))) {
|
|
31
|
-
throw new Error(`The codegen android path defined in your package.json: ${codegenAndroidPath} doesn't exist.`);
|
|
32
|
-
}
|
|
33
|
-
const codegenJavaPackageName = packageJson.codegenConfig.android.javaPackageName;
|
|
34
|
-
if (!codegenJavaPackageName) {
|
|
35
|
-
throw new Error(`Your package.json doesn't contain codegenConfig.android.javaPackageName. Please see ${CODEGEN_DOCS}`);
|
|
36
|
-
}
|
|
37
|
-
const codegenJavaPath = _path.default.resolve(codegenAndroidPath, `java/com/facebook/fbreact/specs`);
|
|
38
|
-
|
|
39
|
-
// If this issue is ever fixed in react-native, this check will prevent the patching from running.
|
|
40
|
-
if (!(await _fsExtra.default.pathExists(codegenJavaPath))) {
|
|
41
|
-
report.info(`Could not find ${_kleur.default.blue(_path.default.relative(projectPath, codegenJavaPath))}. Skipping patching codegen java files.`);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const javaFiles = await _fsExtra.default.readdir(codegenJavaPath);
|
|
45
|
-
await Promise.all(javaFiles.map(async file => {
|
|
46
|
-
const filePath = _path.default.resolve(codegenJavaPath, file);
|
|
47
|
-
const fileContent = await _fsExtra.default.readFile(filePath, 'utf8');
|
|
48
|
-
const newFileContent = fileContent.replace('package com.facebook.fbreact.specs', `package ${codegenJavaPackageName}`);
|
|
49
|
-
await _fsExtra.default.writeFile(filePath, newFileContent);
|
|
50
|
-
}));
|
|
51
|
-
const newPackagePath = _path.default.resolve(codegenAndroidPath, 'java', codegenJavaPackageName.replace(/\./g, _path.default.sep));
|
|
52
|
-
if (!(await _fsExtra.default.pathExists(newPackagePath))) {
|
|
53
|
-
await _fsExtra.default.mkdir(newPackagePath, {
|
|
54
|
-
recursive: true
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
await Promise.all(javaFiles.map(async file => {
|
|
58
|
-
const filePath = _path.default.resolve(codegenJavaPath, file);
|
|
59
|
-
const newFilePath = _path.default.resolve(newPackagePath, file);
|
|
60
|
-
await _fsExtra.default.rename(filePath, newFilePath);
|
|
61
|
-
}));
|
|
62
|
-
if (await _fsExtra.default.pathExists(_path.default.resolve(codegenAndroidPath, 'java/com/facebook/react/viewmanagers'))) {
|
|
63
|
-
// Keep the view managers
|
|
64
|
-
await _fsExtra.default.rm(_path.default.resolve(codegenAndroidPath, 'java/com/facebook/fbreact'), {
|
|
65
|
-
recursive: true
|
|
66
|
-
});
|
|
67
|
-
} else {
|
|
68
|
-
// Delete the entire facebook namespace
|
|
69
|
-
await _fsExtra.default.rm(_path.default.resolve(codegenAndroidPath, 'java/com/facebook'), {
|
|
70
|
-
recursive: true
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=patchCodegenAndroidPackage.js.map
|