react-native-builder-bob 0.21.3 → 0.23.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/lib/index.js +24 -98
- package/lib/index.js.map +1 -1
- package/lib/targets/commonjs.js +4 -7
- package/lib/targets/commonjs.js.map +1 -1
- package/lib/targets/module.js +4 -7
- package/lib/targets/module.js.map +1 -1
- package/lib/targets/typescript.js +36 -67
- package/lib/targets/typescript.js.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils/androidAssemble.js +0 -9
- package/lib/utils/androidAssemble.js.map +1 -1
- package/lib/utils/compile.js +23 -31
- package/lib/utils/compile.js.map +1 -1
- package/lib/utils/logger.js +0 -6
- package/lib/utils/logger.js.map +1 -1
- package/lib/utils/prompts.js +0 -4
- package/lib/utils/prompts.js.map +1 -1
- package/package.json +4 -7
- package/lib/targets/aar.js +0 -89
- package/lib/targets/aar.js.map +0 -1
- package/lib/utils/jetifier.js +0 -38
- package/lib/utils/jetifier.js.map +0 -1
package/lib/index.js
CHANGED
|
@@ -1,52 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _path = _interopRequireDefault(require("path"));
|
|
4
|
-
|
|
5
4
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
6
|
-
|
|
7
5
|
var _kleur = _interopRequireDefault(require("kleur"));
|
|
8
|
-
|
|
9
6
|
var _dedent = _interopRequireDefault(require("dedent"));
|
|
10
|
-
|
|
11
7
|
var _yargs = _interopRequireDefault(require("yargs"));
|
|
12
|
-
|
|
13
8
|
var _cosmiconfig = require("cosmiconfig");
|
|
14
|
-
|
|
15
9
|
var _isGitDirty = _interopRequireDefault(require("is-git-dirty"));
|
|
16
|
-
|
|
17
10
|
var _prompts = _interopRequireDefault(require("./utils/prompts"));
|
|
18
|
-
|
|
19
11
|
var logger = _interopRequireWildcard(require("./utils/logger"));
|
|
20
|
-
|
|
21
|
-
var _aar = _interopRequireDefault(require("./targets/aar"));
|
|
22
|
-
|
|
23
12
|
var _commonjs = _interopRequireDefault(require("./targets/commonjs"));
|
|
24
|
-
|
|
25
13
|
var _module = _interopRequireDefault(require("./targets/module"));
|
|
26
|
-
|
|
27
14
|
var _typescript = _interopRequireDefault(require("./targets/typescript"));
|
|
28
|
-
|
|
29
15
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
30
|
-
|
|
31
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
32
|
-
|
|
33
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
34
|
-
|
|
35
18
|
// eslint-disable-next-line import/no-commonjs
|
|
36
19
|
const {
|
|
37
20
|
name,
|
|
38
21
|
version
|
|
39
22
|
} = require('../package.json');
|
|
40
|
-
|
|
41
23
|
const root = process.cwd();
|
|
42
24
|
const explorer = (0, _cosmiconfig.cosmiconfigSync)(name, {
|
|
43
|
-
searchPlaces: ['package.json', `bob.config.js
|
|
25
|
+
searchPlaces: ['package.json', `bob.config.js`, 'bob.config.cjs']
|
|
44
26
|
});
|
|
45
|
-
const FLOW_PRGAMA_REGEX = /\*?\s*@(flow)\b/m;
|
|
27
|
+
const FLOW_PRGAMA_REGEX = /\*?\s*@(flow)\b/m;
|
|
46
28
|
|
|
29
|
+
// eslint-disable-next-line babel/no-unused-expressions
|
|
47
30
|
_yargs.default.command('init', 'configure the package to use bob', {}, async () => {
|
|
48
|
-
var _pkg$scripts;
|
|
49
|
-
|
|
50
31
|
if ((0, _isGitDirty.default)()) {
|
|
51
32
|
const {
|
|
52
33
|
shouldContinue
|
|
@@ -56,22 +37,17 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
56
37
|
message: `The working directory is not clean. You should commit or stash your changes before configuring bob. Continue anyway?`,
|
|
57
38
|
initial: false
|
|
58
39
|
});
|
|
59
|
-
|
|
60
40
|
if (!shouldContinue) {
|
|
61
41
|
process.exit(0);
|
|
62
42
|
}
|
|
63
43
|
}
|
|
64
|
-
|
|
65
44
|
const pak = _path.default.join(root, 'package.json');
|
|
66
|
-
|
|
67
45
|
if (!(await _fsExtra.default.pathExists(pak))) {
|
|
68
46
|
logger.exit(`Couldn't find a 'package.json' file in '${root}'. Are you in a project folder?`);
|
|
69
47
|
}
|
|
70
|
-
|
|
71
48
|
const pkg = JSON.parse(await _fsExtra.default.readFile(pak, 'utf-8'));
|
|
72
49
|
const result = explorer.search();
|
|
73
|
-
|
|
74
|
-
if (result !== null && result !== void 0 && result.config && pkg.devDependencies && name in pkg.devDependencies) {
|
|
50
|
+
if (result?.config && pkg.devDependencies && name in pkg.devDependencies) {
|
|
75
51
|
const {
|
|
76
52
|
shouldContinue
|
|
77
53
|
} = await (0, _prompts.default)({
|
|
@@ -80,12 +56,10 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
80
56
|
message: `The project seems to be already configured with bob. Do you want to overwrite the existing configuration?`,
|
|
81
57
|
initial: false
|
|
82
58
|
});
|
|
83
|
-
|
|
84
59
|
if (!shouldContinue) {
|
|
85
60
|
process.exit(0);
|
|
86
61
|
}
|
|
87
62
|
}
|
|
88
|
-
|
|
89
63
|
const {
|
|
90
64
|
source
|
|
91
65
|
} = await (0, _prompts.default)({
|
|
@@ -96,7 +70,6 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
96
70
|
validate: input => Boolean(input)
|
|
97
71
|
});
|
|
98
72
|
let entryFile;
|
|
99
|
-
|
|
100
73
|
if (await _fsExtra.default.pathExists(_path.default.join(root, source, 'index.js'))) {
|
|
101
74
|
entryFile = 'index.js';
|
|
102
75
|
} else if (await _fsExtra.default.pathExists(_path.default.join(root, source, 'index.ts'))) {
|
|
@@ -104,12 +77,10 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
104
77
|
} else if (await _fsExtra.default.pathExists(_path.default.join(root, source, 'index.tsx'))) {
|
|
105
78
|
entryFile = 'index.tsx';
|
|
106
79
|
}
|
|
107
|
-
|
|
108
80
|
if (!entryFile) {
|
|
109
81
|
logger.exit(`Couldn't find a 'index.js'. 'index.ts' or 'index.tsx' file under '${source}'. Please re-run the CLI after creating it.`);
|
|
110
82
|
return;
|
|
111
83
|
}
|
|
112
|
-
|
|
113
84
|
pkg.devDependencies = Object.fromEntries([...Object.entries(pkg.devDependencies || {}), [name, `^${version}`]].sort(([a], [b]) => a.localeCompare(b)));
|
|
114
85
|
const questions = [{
|
|
115
86
|
type: 'text',
|
|
@@ -133,14 +104,9 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
133
104
|
title: 'typescript - declaration files for typechecking',
|
|
134
105
|
value: 'typescript',
|
|
135
106
|
selected: /\.tsx?$/.test(entryFile)
|
|
136
|
-
}, {
|
|
137
|
-
title: 'aar - bundle android code to a binary',
|
|
138
|
-
value: 'aar',
|
|
139
|
-
selected: false
|
|
140
107
|
}],
|
|
141
108
|
validate: input => Boolean(input.length)
|
|
142
109
|
}];
|
|
143
|
-
|
|
144
110
|
if (entryFile.endsWith('.js') && FLOW_PRGAMA_REGEX.test(await _fsExtra.default.readFile(_path.default.join(root, source, entryFile), 'utf-8'))) {
|
|
145
111
|
questions.push({
|
|
146
112
|
type: 'confirm',
|
|
@@ -149,7 +115,6 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
149
115
|
initial: Object.keys(pkg.devDependencies || {}).includes('flow-bin')
|
|
150
116
|
});
|
|
151
117
|
}
|
|
152
|
-
|
|
153
118
|
const {
|
|
154
119
|
output,
|
|
155
120
|
targets,
|
|
@@ -158,16 +123,14 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
158
123
|
const target = targets[0] === 'commonjs' || targets[0] === 'module' ? targets[0] : undefined;
|
|
159
124
|
const entries = {
|
|
160
125
|
'main': target ? _path.default.join(output, target, 'index.js') : _path.default.join(source, entryFile),
|
|
161
|
-
'react-native': _path.default.join(source, entryFile)
|
|
126
|
+
'react-native': _path.default.join(source, entryFile),
|
|
127
|
+
'source': _path.default.join(source, entryFile)
|
|
162
128
|
};
|
|
163
|
-
|
|
164
129
|
if (targets.includes('module')) {
|
|
165
130
|
entries.module = _path.default.join(output, 'module', 'index.js');
|
|
166
131
|
}
|
|
167
|
-
|
|
168
132
|
if (targets.includes('typescript')) {
|
|
169
133
|
entries.types = _path.default.join(output, 'typescript', source, 'index.d.ts');
|
|
170
|
-
|
|
171
134
|
if (!(await _fsExtra.default.pathExists(_path.default.join(root, 'tsconfig.json')))) {
|
|
172
135
|
const {
|
|
173
136
|
tsconfig
|
|
@@ -177,10 +140,10 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
177
140
|
message: `You have enabled 'typescript' compilation, but we couldn't find a 'tsconfig.json' in project root. Generate one?`,
|
|
178
141
|
initial: true
|
|
179
142
|
});
|
|
180
|
-
|
|
181
143
|
if (tsconfig) {
|
|
182
|
-
await _fsExtra.default.
|
|
144
|
+
await _fsExtra.default.writeJSON(_path.default.join(root, 'tsconfig.json'), {
|
|
183
145
|
compilerOptions: {
|
|
146
|
+
rootDir: '.',
|
|
184
147
|
allowUnreachableCode: false,
|
|
185
148
|
allowUnusedLabels: false,
|
|
186
149
|
esModuleInterop: true,
|
|
@@ -202,17 +165,16 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
202
165
|
target: 'esnext',
|
|
203
166
|
verbatimModuleSyntax: true
|
|
204
167
|
}
|
|
205
|
-
},
|
|
168
|
+
}, {
|
|
169
|
+
spaces: 2
|
|
170
|
+
});
|
|
206
171
|
}
|
|
207
172
|
}
|
|
208
173
|
}
|
|
209
|
-
|
|
210
|
-
const prepack = 'bob build';
|
|
174
|
+
const prepare = 'bob build';
|
|
211
175
|
const files = [source, output, '!**/__tests__', '!**/__fixtures__', '!**/__mocks__'];
|
|
212
|
-
|
|
213
176
|
for (const key in entries) {
|
|
214
177
|
const entry = entries[key];
|
|
215
|
-
|
|
216
178
|
if (pkg[key] && pkg[key] !== entry) {
|
|
217
179
|
const {
|
|
218
180
|
replace
|
|
@@ -222,7 +184,6 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
222
184
|
message: `Your package.json has the '${key}' field set to '${pkg[key]}'. Do you want to replace it with '${entry}'?`,
|
|
223
185
|
initial: true
|
|
224
186
|
});
|
|
225
|
-
|
|
226
187
|
if (replace) {
|
|
227
188
|
pkg[key] = entry;
|
|
228
189
|
}
|
|
@@ -230,25 +191,22 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
230
191
|
pkg[key] = entry;
|
|
231
192
|
}
|
|
232
193
|
}
|
|
233
|
-
|
|
234
|
-
if ((_pkg$scripts = pkg.scripts) !== null && _pkg$scripts !== void 0 && _pkg$scripts.prepack && pkg.scripts.prepack !== prepack) {
|
|
194
|
+
if (pkg.scripts?.prepare && pkg.scripts.prepare !== prepare) {
|
|
235
195
|
const {
|
|
236
196
|
replace
|
|
237
197
|
} = await (0, _prompts.default)({
|
|
238
198
|
type: 'confirm',
|
|
239
199
|
name: 'replace',
|
|
240
|
-
message: `Your package.json has the 'scripts.
|
|
200
|
+
message: `Your package.json has the 'scripts.prepare' field set to '${pkg.scripts.prepare}'. Do you want to replace it with '${prepare}'?`,
|
|
241
201
|
initial: true
|
|
242
202
|
});
|
|
243
|
-
|
|
244
203
|
if (replace) {
|
|
245
|
-
pkg.scripts.
|
|
204
|
+
pkg.scripts.prepare = prepare;
|
|
246
205
|
}
|
|
247
206
|
} else {
|
|
248
207
|
pkg.scripts = pkg.scripts || {};
|
|
249
|
-
pkg.scripts.
|
|
208
|
+
pkg.scripts.prepare = prepare;
|
|
250
209
|
}
|
|
251
|
-
|
|
252
210
|
if (pkg.files && JSON.stringify(pkg.files.slice().sort()) !== JSON.stringify(files.slice().sort())) {
|
|
253
211
|
const {
|
|
254
212
|
update
|
|
@@ -258,14 +216,12 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
258
216
|
message: `Your package.json already has a 'files' field. Do you want to update it?`,
|
|
259
217
|
initial: true
|
|
260
218
|
});
|
|
261
|
-
|
|
262
219
|
if (update) {
|
|
263
220
|
pkg.files = [...files, ...pkg.files.filter(file => !files.includes(file.replace(/\/$/g, '')))];
|
|
264
221
|
}
|
|
265
222
|
} else {
|
|
266
223
|
pkg.files = files;
|
|
267
224
|
}
|
|
268
|
-
|
|
269
225
|
pkg[name] = {
|
|
270
226
|
source,
|
|
271
227
|
output,
|
|
@@ -275,19 +231,15 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
275
231
|
copyFlow: true
|
|
276
232
|
}];
|
|
277
233
|
}
|
|
278
|
-
|
|
279
234
|
return t;
|
|
280
235
|
})
|
|
281
236
|
};
|
|
282
|
-
|
|
283
237
|
if (pkg.jest) {
|
|
284
238
|
const entry = `<rootDir>/${output}/`;
|
|
285
|
-
|
|
286
239
|
if (pkg.jest.modulePathIgnorePatterns) {
|
|
287
240
|
const {
|
|
288
241
|
modulePathIgnorePatterns
|
|
289
242
|
} = pkg.jest;
|
|
290
|
-
|
|
291
243
|
if (!modulePathIgnorePatterns.includes(entry)) {
|
|
292
244
|
modulePathIgnorePatterns.push(entry);
|
|
293
245
|
}
|
|
@@ -295,26 +247,22 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
295
247
|
pkg.jest.modulePathIgnorePatterns = [entry];
|
|
296
248
|
}
|
|
297
249
|
}
|
|
298
|
-
|
|
299
250
|
pkg.eslintIgnore = pkg.eslintIgnore || ['node_modules/'];
|
|
300
|
-
|
|
301
251
|
if (!pkg.eslintIgnore.includes(`${output}/`)) {
|
|
302
252
|
pkg.eslintIgnore.push(`${output}/`);
|
|
303
253
|
}
|
|
304
|
-
|
|
305
|
-
|
|
254
|
+
await _fsExtra.default.writeJSON(pak, pkg, {
|
|
255
|
+
spaces: 2
|
|
256
|
+
});
|
|
306
257
|
const ignorefiles = [_path.default.join(root, '.gitignore'), _path.default.join(root, '.eslintignore')];
|
|
307
|
-
|
|
308
258
|
for (const ignorefile of ignorefiles) {
|
|
309
259
|
if (await _fsExtra.default.pathExists(ignorefile)) {
|
|
310
260
|
const content = await _fsExtra.default.readFile(ignorefile, 'utf-8');
|
|
311
|
-
|
|
312
261
|
if (!content.split('\n').includes(`${output}/`)) {
|
|
313
262
|
await _fsExtra.default.writeFile(ignorefile, `${content}\n# generated by bob\n${output}/\n`);
|
|
314
263
|
}
|
|
315
264
|
}
|
|
316
265
|
}
|
|
317
|
-
|
|
318
266
|
console.log((0, _dedent.default)(`
|
|
319
267
|
Project ${_kleur.default.yellow(pkg.name)} configured successfully!
|
|
320
268
|
|
|
@@ -325,75 +273,54 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
325
273
|
${_kleur.default.yellow('Good luck!')}
|
|
326
274
|
`));
|
|
327
275
|
}).command('build', 'build files for publishing', {}, async argv => {
|
|
328
|
-
var _options$targets;
|
|
329
|
-
|
|
330
276
|
const result = explorer.search();
|
|
331
|
-
|
|
332
|
-
if (!(result !== null && result !== void 0 && result.config)) {
|
|
277
|
+
if (!result?.config) {
|
|
333
278
|
logger.exit(`No configuration found. Run '${argv.$0} init' to create one automatically.`);
|
|
334
279
|
}
|
|
335
|
-
|
|
336
280
|
const options = result.config;
|
|
337
|
-
|
|
338
|
-
if (!((_options$targets = options.targets) !== null && _options$targets !== void 0 && _options$targets.length)) {
|
|
281
|
+
if (!options.targets?.length) {
|
|
339
282
|
logger.exit(`No targets found in the configuration in '${_path.default.relative(root, result.filepath)}'.`);
|
|
340
283
|
}
|
|
341
|
-
|
|
342
284
|
const source = options.source;
|
|
343
|
-
|
|
344
285
|
if (!source) {
|
|
345
286
|
logger.exit(`No source option found in the configuration in '${_path.default.relative(root, result.filepath)}'.`);
|
|
346
287
|
}
|
|
347
|
-
|
|
348
288
|
const output = options.output;
|
|
349
|
-
|
|
350
289
|
if (!output) {
|
|
351
290
|
logger.exit(`No source option found in the configuration in '${_path.default.relative(root, result.filepath)}'.`);
|
|
352
291
|
}
|
|
353
|
-
|
|
292
|
+
const exclude = options.exclude ?? '**/{__tests__,__fixtures__,__mocks__}/**';
|
|
354
293
|
const report = {
|
|
355
294
|
info: logger.info,
|
|
356
295
|
warn: logger.warn,
|
|
357
296
|
error: logger.error,
|
|
358
297
|
success: logger.success
|
|
359
298
|
};
|
|
360
|
-
|
|
361
299
|
for (const target of options.targets) {
|
|
362
300
|
const targetName = Array.isArray(target) ? target[0] : target;
|
|
363
301
|
const targetOptions = Array.isArray(target) ? target[1] : undefined;
|
|
364
302
|
report.info(`Building target ${_kleur.default.blue(targetName)}`);
|
|
365
|
-
|
|
366
303
|
switch (targetName) {
|
|
367
|
-
case 'aar':
|
|
368
|
-
await (0, _aar.default)({
|
|
369
|
-
root,
|
|
370
|
-
source: _path.default.resolve(root, source),
|
|
371
|
-
output: _path.default.resolve(root, output, 'aar'),
|
|
372
|
-
options: targetOptions,
|
|
373
|
-
report
|
|
374
|
-
});
|
|
375
|
-
break;
|
|
376
|
-
|
|
377
304
|
case 'commonjs':
|
|
378
305
|
await (0, _commonjs.default)({
|
|
379
306
|
root,
|
|
380
307
|
source: _path.default.resolve(root, source),
|
|
381
308
|
output: _path.default.resolve(root, output, 'commonjs'),
|
|
309
|
+
exclude,
|
|
382
310
|
options: targetOptions,
|
|
383
311
|
report
|
|
384
312
|
});
|
|
385
313
|
break;
|
|
386
|
-
|
|
387
314
|
case 'module':
|
|
388
315
|
await (0, _module.default)({
|
|
389
316
|
root,
|
|
390
317
|
source: _path.default.resolve(root, source),
|
|
391
318
|
output: _path.default.resolve(root, output, 'module'),
|
|
319
|
+
exclude,
|
|
392
320
|
options: targetOptions,
|
|
393
321
|
report
|
|
394
322
|
});
|
|
395
323
|
break;
|
|
396
|
-
|
|
397
324
|
case 'typescript':
|
|
398
325
|
await (0, _typescript.default)({
|
|
399
326
|
root,
|
|
@@ -403,7 +330,6 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
403
330
|
report
|
|
404
331
|
});
|
|
405
332
|
break;
|
|
406
|
-
|
|
407
333
|
default:
|
|
408
334
|
logger.exit(`Invalid target ${_kleur.default.blue(targetName)}.`);
|
|
409
335
|
}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["name","version","require","root","process","cwd","explorer","cosmiconfigSync","searchPlaces","FLOW_PRGAMA_REGEX","yargs","command","isGitDirty","shouldContinue","prompts","type","message","initial","exit","pak","path","join","fs","pathExists","logger","pkg","JSON","parse","readFile","result","search","config","devDependencies","source","validate","input","Boolean","entryFile","Object","fromEntries","entries","sort","a","b","localeCompare","questions","choices","title","value","selected","test","length","endsWith","push","keys","includes","output","targets","flow","target","undefined","module","types","tsconfig","writeFile","stringify","compilerOptions","allowUnreachableCode","allowUnusedLabels","esModuleInterop","forceConsistentCasingInFileNames","jsx","lib","moduleResolution","noFallthroughCasesInSwitch","noImplicitReturns","noImplicitUseStrict","noStrictGenericChecks","noUncheckedIndexedAccess","noUnusedLocals","noUnusedParameters","resolveJsonModule","skipLibCheck","strict","verbatimModuleSyntax","prepack","files","key","entry","replace","scripts","slice","update","filter","file","map","t","copyFlow","jest","modulePathIgnorePatterns","eslintIgnore","ignorefiles","ignorefile","content","split","console","log","dedent","kleur","yellow","magenta","bold","gray","argv","$0","options","relative","filepath","report","info","warn","error","success","targetName","Array","isArray","targetOptions","blue","buildAAR","resolve","buildCommonJS","buildModule","buildTypescript","demandCommand","recommendCommands"],"sources":["../src/index.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs-extra';\nimport kleur from 'kleur';\nimport dedent from 'dedent';\nimport yargs from 'yargs';\nimport { cosmiconfigSync } from 'cosmiconfig';\nimport isGitDirty from 'is-git-dirty';\nimport prompts, { type PromptObject } from './utils/prompts';\nimport * as logger from './utils/logger';\nimport buildAAR from './targets/aar';\nimport buildCommonJS from './targets/commonjs';\nimport buildModule from './targets/module';\nimport buildTypescript from './targets/typescript';\nimport type { Options } from './types';\n\n// eslint-disable-next-line import/no-commonjs\nconst { name, version } = require('../package.json');\n\nconst root = process.cwd();\nconst explorer = cosmiconfigSync(name, {\n searchPlaces: ['package.json', `bob.config.js`],\n});\n\nconst FLOW_PRGAMA_REGEX = /\\*?\\s*@(flow)\\b/m;\n\n// eslint-disable-next-line babel/no-unused-expressions\nyargs\n .command('init', 'configure the package to use bob', {}, async () => {\n if (isGitDirty()) {\n const { shouldContinue } = await prompts({\n type: 'confirm',\n name: 'shouldContinue',\n message: `The working directory is not clean. You should commit or stash your changes before configuring bob. Continue anyway?`,\n initial: false,\n });\n\n if (!shouldContinue) {\n process.exit(0);\n }\n }\n\n const pak = path.join(root, 'package.json');\n\n if (!(await fs.pathExists(pak))) {\n logger.exit(\n `Couldn't find a 'package.json' file in '${root}'. Are you in a project folder?`\n );\n }\n\n const pkg = JSON.parse(await fs.readFile(pak, 'utf-8'));\n const result = explorer.search();\n\n if (result?.config && pkg.devDependencies && name in pkg.devDependencies) {\n const { shouldContinue } = await prompts({\n type: 'confirm',\n name: 'shouldContinue',\n message: `The project seems to be already configured with bob. Do you want to overwrite the existing configuration?`,\n initial: false,\n });\n\n if (!shouldContinue) {\n process.exit(0);\n }\n }\n\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 });\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 logger.exit(\n `Couldn't find a 'index.js'. 'index.ts' or 'index.tsx' file under '${source}'. Please re-run the CLI after creating it.`\n );\n return;\n }\n\n pkg.devDependencies = Object.fromEntries(\n [\n ...Object.entries(pkg.devDependencies || {}),\n [name, `^${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: 'commonjs - for running in Node (tests, SSR etc.)',\n value: 'commonjs',\n selected: true,\n },\n {\n title: 'module - for bundlers (metro, webpack etc.)',\n value: 'module',\n selected: true,\n },\n {\n title: 'typescript - declaration files for typechecking',\n value: 'typescript',\n selected: /\\.tsx?$/.test(entryFile),\n },\n {\n title: 'aar - bundle android code to a binary',\n value: 'aar',\n selected: false,\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 const { output, targets, flow } = await prompts(questions);\n\n const target =\n targets[0] === 'commonjs' || targets[0] === 'module'\n ? targets[0]\n : undefined;\n\n const entries: { [key: string]: string } = {\n 'main': target\n ? path.join(output, target, 'index.js')\n : path.join(source, entryFile),\n 'react-native': path.join(source, entryFile),\n };\n\n if (targets.includes('module')) {\n entries.module = path.join(output, 'module', 'index.js');\n }\n\n if (targets.includes('typescript')) {\n entries.types = path.join(output, 'typescript', source, 'index.d.ts');\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. Generate one?`,\n initial: true,\n });\n\n if (tsconfig) {\n await fs.writeFile(\n path.join(root, 'tsconfig.json'),\n JSON.stringify(\n {\n compilerOptions: {\n allowUnreachableCode: false,\n allowUnusedLabels: false,\n esModuleInterop: true,\n forceConsistentCasingInFileNames: true,\n jsx: 'react',\n lib: ['esnext'],\n module: 'esnext',\n moduleResolution: 'node',\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 null,\n 2\n )\n );\n }\n }\n }\n\n const prepack = 'bob build';\n const files = [\n source,\n output,\n '!**/__tests__',\n '!**/__fixtures__',\n '!**/__mocks__',\n ];\n\n for (const key in entries) {\n const entry = entries[key];\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 '${pkg[key]}'. Do you want to replace it with '${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 (pkg.scripts?.prepack && pkg.scripts.prepack !== prepack) {\n const { replace } = await prompts({\n type: 'confirm',\n name: 'replace',\n message: `Your package.json has the 'scripts.prepack' field set to '${pkg.scripts.prepack}'. Do you want to replace it with '${prepack}'?`,\n initial: true,\n });\n\n if (replace) {\n pkg.scripts.prepack = prepack;\n }\n } else {\n pkg.scripts = pkg.scripts || {};\n pkg.scripts.prepack = prepack;\n }\n\n if (\n pkg.files &&\n JSON.stringify(pkg.files.slice().sort()) !==\n JSON.stringify(files.slice().sort())\n ) {\n const { update } = await prompts({\n type: 'confirm',\n name: 'update',\n message: `Your package.json already has a 'files' field. Do you want to update it?`,\n initial: true,\n });\n\n if (update) {\n pkg.files = [\n ...files,\n ...pkg.files.filter(\n (file: string) => !files.includes(file.replace(/\\/$/g, ''))\n ),\n ];\n }\n } else {\n pkg.files = files;\n }\n\n pkg[name] = {\n source,\n output,\n targets: targets.map((t: string) => {\n if (t === target && flow) {\n return [t, { copyFlow: true }];\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.writeFile(pak, JSON.stringify(pkg, null, 2));\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 console.log(\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(':')} yarn\n\n ${kleur.yellow('Good luck!')}\n `)\n );\n })\n .command('build', 'build files for publishing', {}, async (argv) => {\n const result = explorer.search();\n\n if (!result?.config) {\n logger.exit(\n `No configuration found. Run '${argv.$0} init' to create one automatically.`\n );\n }\n\n const options: Options = result!.config;\n\n if (!options.targets?.length) {\n logger.exit(\n `No targets found in the configuration in '${path.relative(\n root,\n result!.filepath\n )}'.`\n );\n }\n\n const source = options.source;\n\n if (!source) {\n logger.exit(\n `No source option found in the configuration in '${path.relative(\n root,\n result!.filepath\n )}'.`\n );\n }\n\n const output = options.output;\n\n if (!output) {\n logger.exit(\n `No source option found in the configuration in '${path.relative(\n root,\n result!.filepath\n )}'.`\n );\n }\n\n const report = {\n info: logger.info,\n warn: logger.warn,\n error: logger.error,\n success: logger.success,\n };\n\n for (const target of options.targets!) {\n const targetName = Array.isArray(target) ? target[0] : target;\n const targetOptions = Array.isArray(target) ? target[1] : undefined;\n\n report.info(`Building target ${kleur.blue(targetName)}`);\n\n switch (targetName) {\n case 'aar':\n await buildAAR({\n root,\n source: path.resolve(root, source as string),\n output: path.resolve(root, output as string, 'aar'),\n options: targetOptions,\n report,\n });\n break;\n case 'commonjs':\n await buildCommonJS({\n root,\n source: path.resolve(root, source as string),\n output: path.resolve(root, output as string, 'commonjs'),\n options: targetOptions,\n report,\n });\n break;\n case 'module':\n await buildModule({\n root,\n source: path.resolve(root, source as string),\n output: path.resolve(root, output as string, 'module'),\n options: targetOptions,\n report,\n });\n break;\n case 'typescript':\n await buildTypescript({\n root,\n source: path.resolve(root, source as string),\n output: path.resolve(root, output as string, 'typescript'),\n options: targetOptions,\n report,\n });\n break;\n default:\n logger.exit(`Invalid target ${kleur.blue(targetName)}.`);\n }\n }\n })\n .demandCommand()\n .recommendCommands()\n .strict().argv;\n"],"mappings":";;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAC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,QAAL;QACE,MAAM,IAAAa,eAAA,EAAY;UAChBhI,IADgB;UAEhB8B,MAAM,EAAEb,aAAA,CAAK6G,OAAL,CAAa9H,IAAb,EAAmB8B,MAAnB,CAFQ;UAGhBuB,MAAM,EAAEpC,aAAA,CAAK6G,OAAL,CAAa9H,IAAb,EAAmBqD,MAAnB,EAAqC,QAArC,CAHQ;UAIhB2D,OAAO,EAAEW,aAJO;UAKhBR;QALgB,CAAZ,CAAN;QAOA;;MACF,KAAK,YAAL;QACE,MAAM,IAAAc,mBAAA,EAAgB;UACpBjI,IADoB;UAEpB8B,MAAM,EAAEb,aAAA,CAAK6G,OAAL,CAAa9H,IAAb,EAAmB8B,MAAnB,CAFY;UAGpBuB,MAAM,EAAEpC,aAAA,CAAK6G,OAAL,CAAa9H,IAAb,EAAmBqD,MAAnB,EAAqC,YAArC,CAHY;UAIpB2D,OAAO,EAAEW,aAJW;UAKpBR;QALoB,CAAhB,CAAN;QAOA;;MACF;QACE9F,MAAM,CAACN,IAAP,CAAa,kBAAiB0F,cAAA,CAAMmB,IAAN,CAAWJ,UAAX,CAAuB,GAArD;IAtCJ;EAwCD;AACF,CAlaH,EAmaGU,aAnaH,GAoaGC,iBApaH,GAqaGnD,MAraH,GAqaY8B,IAraZ"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_path","_interopRequireDefault","require","_fsExtra","_kleur","_dedent","_yargs","_cosmiconfig","_isGitDirty","_prompts","logger","_interopRequireWildcard","_commonjs","_module","_typescript","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","name","version","root","process","cwd","explorer","cosmiconfigSync","searchPlaces","FLOW_PRGAMA_REGEX","yargs","command","isGitDirty","shouldContinue","prompts","type","message","initial","exit","pak","path","join","fs","pathExists","pkg","JSON","parse","readFile","result","search","config","devDependencies","source","validate","input","Boolean","entryFile","fromEntries","entries","sort","a","b","localeCompare","questions","choices","title","value","selected","test","length","endsWith","push","keys","includes","output","targets","flow","target","undefined","module","types","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","entry","replace","scripts","stringify","slice","update","filter","file","map","t","copyFlow","jest","modulePathIgnorePatterns","eslintIgnore","ignorefiles","ignorefile","content","split","writeFile","console","log","dedent","kleur","yellow","magenta","bold","gray","argv","$0","options","relative","filepath","exclude","report","info","warn","error","success","targetName","Array","isArray","targetOptions","blue","buildCommonJS","resolve","buildModule","buildTypescript","demandCommand","recommendCommands"],"sources":["../src/index.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs-extra';\nimport kleur from 'kleur';\nimport dedent from 'dedent';\nimport yargs from 'yargs';\nimport { cosmiconfigSync } from 'cosmiconfig';\nimport isGitDirty from 'is-git-dirty';\nimport prompts, { type PromptObject } from './utils/prompts';\nimport * as logger from './utils/logger';\nimport buildCommonJS from './targets/commonjs';\nimport buildModule from './targets/module';\nimport buildTypescript from './targets/typescript';\nimport type { Options } from './types';\n\n// eslint-disable-next-line import/no-commonjs\nconst { name, version } = require('../package.json');\n\nconst root = process.cwd();\nconst explorer = cosmiconfigSync(name, {\n searchPlaces: ['package.json', `bob.config.js`, 'bob.config.cjs'],\n});\n\nconst FLOW_PRGAMA_REGEX = /\\*?\\s*@(flow)\\b/m;\n\n// eslint-disable-next-line babel/no-unused-expressions\nyargs\n .command('init', 'configure the package to use bob', {}, async () => {\n if (isGitDirty()) {\n const { shouldContinue } = await prompts({\n type: 'confirm',\n name: 'shouldContinue',\n message: `The working directory is not clean. You should commit or stash your changes before configuring bob. Continue anyway?`,\n initial: false,\n });\n\n if (!shouldContinue) {\n process.exit(0);\n }\n }\n\n const pak = path.join(root, 'package.json');\n\n if (!(await fs.pathExists(pak))) {\n logger.exit(\n `Couldn't find a 'package.json' file in '${root}'. Are you in a project folder?`\n );\n }\n\n const pkg = JSON.parse(await fs.readFile(pak, 'utf-8'));\n const result = explorer.search();\n\n if (result?.config && pkg.devDependencies && name in pkg.devDependencies) {\n const { shouldContinue } = await prompts({\n type: 'confirm',\n name: 'shouldContinue',\n message: `The project seems to be already configured with bob. Do you want to overwrite the existing configuration?`,\n initial: false,\n });\n\n if (!shouldContinue) {\n process.exit(0);\n }\n }\n\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 });\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 logger.exit(\n `Couldn't find a 'index.js'. 'index.ts' or 'index.tsx' file under '${source}'. Please re-run the CLI after creating it.`\n );\n return;\n }\n\n pkg.devDependencies = Object.fromEntries(\n [\n ...Object.entries(pkg.devDependencies || {}),\n [name, `^${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: 'commonjs - for running in Node (tests, SSR etc.)',\n value: 'commonjs',\n selected: true,\n },\n {\n title: 'module - for bundlers (metro, webpack etc.)',\n value: 'module',\n selected: true,\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 const { output, targets, flow } = await prompts(questions);\n\n const target =\n targets[0] === 'commonjs' || targets[0] === 'module'\n ? targets[0]\n : undefined;\n\n const entries: { [key: string]: string } = {\n 'main': target\n ? path.join(output, target, 'index.js')\n : path.join(source, entryFile),\n 'react-native': path.join(source, entryFile),\n 'source': path.join(source, entryFile),\n };\n\n if (targets.includes('module')) {\n entries.module = path.join(output, 'module', 'index.js');\n }\n\n if (targets.includes('typescript')) {\n entries.types = path.join(output, 'typescript', source, 'index.d.ts');\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. 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',\n lib: ['esnext'],\n module: 'esnext',\n moduleResolution: 'node',\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 for (const key in entries) {\n const entry = entries[key];\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 '${pkg[key]}'. Do you want to replace it with '${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 (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 '${pkg.scripts.prepare}'. 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 (\n pkg.files &&\n JSON.stringify(pkg.files.slice().sort()) !==\n JSON.stringify(files.slice().sort())\n ) {\n const { update } = await prompts({\n type: 'confirm',\n name: 'update',\n message: `Your package.json already has a 'files' field. Do you want to update it?`,\n initial: true,\n });\n\n if (update) {\n pkg.files = [\n ...files,\n ...pkg.files.filter(\n (file: string) => !files.includes(file.replace(/\\/$/g, ''))\n ),\n ];\n }\n } else {\n pkg.files = files;\n }\n\n pkg[name] = {\n source,\n output,\n targets: targets.map((t: string) => {\n if (t === target && flow) {\n return [t, { copyFlow: true }];\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(pak, 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 console.log(\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(':')} yarn\n\n ${kleur.yellow('Good luck!')}\n `)\n );\n })\n .command('build', 'build files for publishing', {}, async (argv) => {\n const result = explorer.search();\n\n if (!result?.config) {\n logger.exit(\n `No configuration found. Run '${argv.$0} init' to create one automatically.`\n );\n }\n\n const options: Options = result!.config;\n\n if (!options.targets?.length) {\n logger.exit(\n `No targets found in the configuration in '${path.relative(\n root,\n result!.filepath\n )}'.`\n );\n }\n\n const source = options.source;\n\n if (!source) {\n logger.exit(\n `No source option found in the configuration in '${path.relative(\n root,\n result!.filepath\n )}'.`\n );\n }\n\n const output = options.output;\n\n if (!output) {\n logger.exit(\n `No source option found in the configuration in '${path.relative(\n root,\n result!.filepath\n )}'.`\n );\n }\n\n const exclude =\n options.exclude ?? '**/{__tests__,__fixtures__,__mocks__}/**';\n\n const report = {\n info: logger.info,\n warn: logger.warn,\n error: logger.error,\n success: logger.success,\n };\n\n for (const target of options.targets!) {\n const targetName = Array.isArray(target) ? target[0] : target;\n const targetOptions = Array.isArray(target) ? target[1] : undefined;\n\n report.info(`Building target ${kleur.blue(targetName)}`);\n\n switch (targetName) {\n case 'commonjs':\n await buildCommonJS({\n root,\n source: path.resolve(root, source as string),\n output: path.resolve(root, output as string, 'commonjs'),\n exclude,\n options: targetOptions,\n report,\n });\n break;\n case 'module':\n await buildModule({\n root,\n source: path.resolve(root, source as string),\n output: path.resolve(root, output as string, 'module'),\n exclude,\n options: targetOptions,\n report,\n });\n break;\n case 'typescript':\n await buildTypescript({\n root,\n source: path.resolve(root, source as string),\n output: path.resolve(root, output as string, 'typescript'),\n options: targetOptions,\n report,\n });\n break;\n default:\n logger.exit(`Invalid target ${kleur.blue(targetName)}.`);\n }\n }\n })\n .demandCommand()\n .recommendCommands()\n .strict().argv;\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,MAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,QAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,MAAA,GAAAC,uBAAA,CAAAT,OAAA;AACA,IAAAU,SAAA,GAAAX,sBAAA,CAAAC,OAAA;AACA,IAAAW,OAAA,GAAAZ,sBAAA,CAAAC,OAAA;AACA,IAAAY,WAAA,GAAAb,sBAAA,CAAAC,OAAA;AAAmD,SAAAa,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAL,wBAAAS,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,G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E6B,MAAgB,CAAC;UAC5CsB,MAAM,EAAElC,aAAI,CAAC8G,OAAO,CAAC/H,IAAI,EAAEmD,MAAM,EAAY,UAAU,CAAC;UACxDgE,OAAO;UACPH,OAAO,EAAEY,aAAa;UACtBR;QACF,CAAC,CAAC;QACF;MACF,KAAK,QAAQ;QACX,MAAM,IAAAY,eAAW,EAAC;UAChBhI,IAAI;UACJ6B,MAAM,EAAEZ,aAAI,CAAC8G,OAAO,CAAC/H,IAAI,EAAE6B,MAAgB,CAAC;UAC5CsB,MAAM,EAAElC,aAAI,CAAC8G,OAAO,CAAC/H,IAAI,EAAEmD,MAAM,EAAY,QAAQ,CAAC;UACtDgE,OAAO;UACPH,OAAO,EAAEY,aAAa;UACtBR;QACF,CAAC,CAAC;QACF;MACF,KAAK,YAAY;QACf,MAAM,IAAAa,mBAAe,EAAC;UACpBjI,IAAI;UACJ6B,MAAM,EAAEZ,aAAI,CAAC8G,OAAO,CAAC/H,IAAI,EAAE6B,MAAgB,CAAC;UAC5CsB,MAAM,EAAElC,aAAI,CAAC8G,OAAO,CAAC/H,IAAI,EAAEmD,MAAM,EAAY,YAAY,CAAC;UAC1D6D,OAAO,EAAEY,aAAa;UACtBR;QACF,CAAC,CAAC;QACF;MACF;QACEjJ,MAAM,CAAC4C,IAAI,CAAE,kBAAiB0F,cAAK,CAACoB,IAAI,CAACJ,UAAU,CAAE,GAAE,CAAC;IAC5D;EACF;AACF,CAAC,CAAC,CACDS,aAAa,CAAC,CAAC,CACfC,iBAAiB,CAAC,CAAC,CACnBrD,MAAM,CAAC,CAAC,CAACgC,IAAI"}
|
package/lib/targets/commonjs.js
CHANGED
|
@@ -4,30 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = build;
|
|
7
|
-
|
|
8
7
|
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
8
|
var _kleur = _interopRequireDefault(require("kleur"));
|
|
11
|
-
|
|
12
9
|
var _del = _interopRequireDefault(require("del"));
|
|
13
|
-
|
|
14
10
|
var _compile = _interopRequireDefault(require("../utils/compile"));
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
12
|
async function build({
|
|
19
13
|
root,
|
|
20
14
|
source,
|
|
21
15
|
output,
|
|
16
|
+
exclude,
|
|
22
17
|
options,
|
|
23
18
|
report
|
|
24
19
|
}) {
|
|
25
20
|
report.info(`Cleaning up previous build at ${_kleur.default.blue(_path.default.relative(root, output))}`);
|
|
26
21
|
await (0, _del.default)([output]);
|
|
27
|
-
await (0, _compile.default)({
|
|
22
|
+
await (0, _compile.default)({
|
|
23
|
+
...options,
|
|
28
24
|
root,
|
|
29
25
|
source,
|
|
30
26
|
output,
|
|
27
|
+
exclude,
|
|
31
28
|
modules: 'commonjs',
|
|
32
29
|
report,
|
|
33
30
|
field: 'main'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commonjs.js","names":["build","root","source","output","options","report","info","kleur","blue","path","relative","del","compile","modules","field"],"sources":["../../src/targets/commonjs.ts"],"sourcesContent":["import path from 'path';\nimport kleur from 'kleur';\nimport del from 'del';\nimport compile from '../utils/compile';\nimport type { Input } from '../types';\n\ntype Options = Input & {\n options?: {\n babelrc?: boolean | null;\n configFile?: string | false | null;\n sourceMaps?: boolean;\n copyFlow?: boolean;\n };\n};\n\nexport default async function build({\n root,\n source,\n output,\n options,\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 root,\n source,\n output,\n modules: 'commonjs',\n report,\n field: 'main',\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"commonjs.js","names":["_path","_interopRequireDefault","require","_kleur","_del","_compile","obj","__esModule","default","build","root","source","output","exclude","options","report","info","kleur","blue","path","relative","del","compile","modules","field"],"sources":["../../src/targets/commonjs.ts"],"sourcesContent":["import path from 'path';\nimport kleur from 'kleur';\nimport del from 'del';\nimport compile from '../utils/compile';\nimport type { Input } from '../types';\n\ntype Options = Input & {\n options?: {\n babelrc?: boolean | null;\n configFile?: string | false | null;\n sourceMaps?: boolean;\n copyFlow?: boolean;\n };\n exclude: string;\n};\n\nexport default async function build({\n root,\n source,\n output,\n exclude,\n options,\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 root,\n source,\n output,\n exclude,\n modules: 'commonjs',\n report,\n field: 'main',\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;AAAuC,SAAAD,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAaxB,eAAeG,KAAKA,CAAC;EAClCC,IAAI;EACJC,MAAM;EACNC,MAAM;EACNC,OAAO;EACPC,OAAO;EACPC;AACO,CAAC,EAAE;EACVA,MAAM,CAACC,IAAI,CACR,iCAAgCC,cAAK,CAACC,IAAI,CAACC,aAAI,CAACC,QAAQ,CAACV,IAAI,EAAEE,MAAM,CAAC,CAAE,EAC3E,CAAC;EAED,MAAM,IAAAS,YAAG,EAAC,CAACT,MAAM,CAAC,CAAC;EAEnB,MAAM,IAAAU,gBAAO,EAAC;IACZ,GAAGR,OAAO;IACVJ,IAAI;IACJC,MAAM;IACNC,MAAM;IACNC,OAAO;IACPU,OAAO,EAAE,UAAU;IACnBR,MAAM;IACNS,KAAK,EAAE;EACT,CAAC,CAAC;AACJ"}
|
package/lib/targets/module.js
CHANGED
|
@@ -4,30 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = build;
|
|
7
|
-
|
|
8
7
|
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
8
|
var _kleur = _interopRequireDefault(require("kleur"));
|
|
11
|
-
|
|
12
9
|
var _del = _interopRequireDefault(require("del"));
|
|
13
|
-
|
|
14
10
|
var _compile = _interopRequireDefault(require("../utils/compile"));
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
12
|
async function build({
|
|
19
13
|
root,
|
|
20
14
|
source,
|
|
21
15
|
output,
|
|
16
|
+
exclude,
|
|
22
17
|
options,
|
|
23
18
|
report
|
|
24
19
|
}) {
|
|
25
20
|
report.info(`Cleaning up previous build at ${_kleur.default.blue(_path.default.relative(root, output))}`);
|
|
26
21
|
await (0, _del.default)([output]);
|
|
27
|
-
await (0, _compile.default)({
|
|
22
|
+
await (0, _compile.default)({
|
|
23
|
+
...options,
|
|
28
24
|
root,
|
|
29
25
|
source,
|
|
30
26
|
output,
|
|
27
|
+
exclude,
|
|
31
28
|
modules: false,
|
|
32
29
|
report,
|
|
33
30
|
field: 'module'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","names":["build","root","source","output","options","report","info","kleur","blue","path","relative","del","compile","modules","field"],"sources":["../../src/targets/module.ts"],"sourcesContent":["import path from 'path';\nimport kleur from 'kleur';\nimport del from 'del';\nimport compile from '../utils/compile';\nimport type { Input } from '../types';\n\ntype Options = Input & {\n options?: {\n babelrc?: boolean | null;\n configFile?: string | false | null;\n sourceMaps?: boolean;\n copyFlow?: boolean;\n };\n};\n\nexport default async function build({\n root,\n source,\n output,\n options,\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 root,\n source,\n output,\n modules: false,\n report,\n field: 'module',\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"module.js","names":["_path","_interopRequireDefault","require","_kleur","_del","_compile","obj","__esModule","default","build","root","source","output","exclude","options","report","info","kleur","blue","path","relative","del","compile","modules","field"],"sources":["../../src/targets/module.ts"],"sourcesContent":["import path from 'path';\nimport kleur from 'kleur';\nimport del from 'del';\nimport compile from '../utils/compile';\nimport type { Input } from '../types';\n\ntype Options = Input & {\n options?: {\n babelrc?: boolean | null;\n configFile?: string | false | null;\n sourceMaps?: boolean;\n copyFlow?: boolean;\n };\n exclude: string;\n};\n\nexport default async function build({\n root,\n source,\n output,\n exclude,\n options,\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 root,\n source,\n output,\n exclude,\n modules: false,\n report,\n field: 'module',\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;AAAuC,SAAAD,uBAAAK,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAaxB,eAAeG,KAAKA,CAAC;EAClCC,IAAI;EACJC,MAAM;EACNC,MAAM;EACNC,OAAO;EACPC,OAAO;EACPC;AACO,CAAC,EAAE;EACVA,MAAM,CAACC,IAAI,CACR,iCAAgCC,cAAK,CAACC,IAAI,CAACC,aAAI,CAACC,QAAQ,CAACV,IAAI,EAAEE,MAAM,CAAC,CAAE,EAC3E,CAAC;EAED,MAAM,IAAAS,YAAG,EAAC,CAACT,MAAM,CAAC,CAAC;EAEnB,MAAM,IAAAU,gBAAO,EAAC;IACZ,GAAGR,OAAO;IACVJ,IAAI;IACJC,MAAM;IACNC,MAAM;IACNC,OAAO;IACPU,OAAO,EAAE,KAAK;IACdR,MAAM;IACNS,KAAK,EAAE;EACT,CAAC,CAAC;AACJ"}
|