react-native-builder-bob 0.22.0 → 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 +14 -73
- package/lib/index.js.map +1 -1
- package/lib/targets/commonjs.js +2 -7
- package/lib/targets/commonjs.js.map +1 -1
- package/lib/targets/module.js +2 -7
- package/lib/targets/module.js.map +1 -1
- package/lib/targets/typescript.js +4 -41
- package/lib/targets/typescript.js.map +1 -1
- package/lib/utils/androidAssemble.js +0 -9
- package/lib/utils/androidAssemble.js.map +1 -1
- package/lib/utils/compile.js +3 -33
- 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 +3 -3
package/lib/index.js
CHANGED
|
@@ -1,47 +1,32 @@
|
|
|
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
12
|
var _commonjs = _interopRequireDefault(require("./targets/commonjs"));
|
|
22
|
-
|
|
23
13
|
var _module = _interopRequireDefault(require("./targets/module"));
|
|
24
|
-
|
|
25
14
|
var _typescript = _interopRequireDefault(require("./targets/typescript"));
|
|
26
|
-
|
|
27
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); }
|
|
28
|
-
|
|
29
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; }
|
|
30
|
-
|
|
31
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
32
|
-
|
|
33
18
|
// eslint-disable-next-line import/no-commonjs
|
|
34
19
|
const {
|
|
35
20
|
name,
|
|
36
21
|
version
|
|
37
22
|
} = require('../package.json');
|
|
38
|
-
|
|
39
23
|
const root = process.cwd();
|
|
40
24
|
const explorer = (0, _cosmiconfig.cosmiconfigSync)(name, {
|
|
41
25
|
searchPlaces: ['package.json', `bob.config.js`, 'bob.config.cjs']
|
|
42
26
|
});
|
|
43
|
-
const FLOW_PRGAMA_REGEX = /\*?\s*@(flow)\b/m;
|
|
27
|
+
const FLOW_PRGAMA_REGEX = /\*?\s*@(flow)\b/m;
|
|
44
28
|
|
|
29
|
+
// eslint-disable-next-line babel/no-unused-expressions
|
|
45
30
|
_yargs.default.command('init', 'configure the package to use bob', {}, async () => {
|
|
46
31
|
if ((0, _isGitDirty.default)()) {
|
|
47
32
|
const {
|
|
@@ -52,21 +37,16 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
52
37
|
message: `The working directory is not clean. You should commit or stash your changes before configuring bob. Continue anyway?`,
|
|
53
38
|
initial: false
|
|
54
39
|
});
|
|
55
|
-
|
|
56
40
|
if (!shouldContinue) {
|
|
57
41
|
process.exit(0);
|
|
58
42
|
}
|
|
59
43
|
}
|
|
60
|
-
|
|
61
44
|
const pak = _path.default.join(root, 'package.json');
|
|
62
|
-
|
|
63
45
|
if (!(await _fsExtra.default.pathExists(pak))) {
|
|
64
46
|
logger.exit(`Couldn't find a 'package.json' file in '${root}'. Are you in a project folder?`);
|
|
65
47
|
}
|
|
66
|
-
|
|
67
48
|
const pkg = JSON.parse(await _fsExtra.default.readFile(pak, 'utf-8'));
|
|
68
49
|
const result = explorer.search();
|
|
69
|
-
|
|
70
50
|
if (result?.config && pkg.devDependencies && name in pkg.devDependencies) {
|
|
71
51
|
const {
|
|
72
52
|
shouldContinue
|
|
@@ -76,12 +56,10 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
76
56
|
message: `The project seems to be already configured with bob. Do you want to overwrite the existing configuration?`,
|
|
77
57
|
initial: false
|
|
78
58
|
});
|
|
79
|
-
|
|
80
59
|
if (!shouldContinue) {
|
|
81
60
|
process.exit(0);
|
|
82
61
|
}
|
|
83
62
|
}
|
|
84
|
-
|
|
85
63
|
const {
|
|
86
64
|
source
|
|
87
65
|
} = await (0, _prompts.default)({
|
|
@@ -92,7 +70,6 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
92
70
|
validate: input => Boolean(input)
|
|
93
71
|
});
|
|
94
72
|
let entryFile;
|
|
95
|
-
|
|
96
73
|
if (await _fsExtra.default.pathExists(_path.default.join(root, source, 'index.js'))) {
|
|
97
74
|
entryFile = 'index.js';
|
|
98
75
|
} else if (await _fsExtra.default.pathExists(_path.default.join(root, source, 'index.ts'))) {
|
|
@@ -100,12 +77,10 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
100
77
|
} else if (await _fsExtra.default.pathExists(_path.default.join(root, source, 'index.tsx'))) {
|
|
101
78
|
entryFile = 'index.tsx';
|
|
102
79
|
}
|
|
103
|
-
|
|
104
80
|
if (!entryFile) {
|
|
105
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.`);
|
|
106
82
|
return;
|
|
107
83
|
}
|
|
108
|
-
|
|
109
84
|
pkg.devDependencies = Object.fromEntries([...Object.entries(pkg.devDependencies || {}), [name, `^${version}`]].sort(([a], [b]) => a.localeCompare(b)));
|
|
110
85
|
const questions = [{
|
|
111
86
|
type: 'text',
|
|
@@ -132,7 +107,6 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
132
107
|
}],
|
|
133
108
|
validate: input => Boolean(input.length)
|
|
134
109
|
}];
|
|
135
|
-
|
|
136
110
|
if (entryFile.endsWith('.js') && FLOW_PRGAMA_REGEX.test(await _fsExtra.default.readFile(_path.default.join(root, source, entryFile), 'utf-8'))) {
|
|
137
111
|
questions.push({
|
|
138
112
|
type: 'confirm',
|
|
@@ -141,7 +115,6 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
141
115
|
initial: Object.keys(pkg.devDependencies || {}).includes('flow-bin')
|
|
142
116
|
});
|
|
143
117
|
}
|
|
144
|
-
|
|
145
118
|
const {
|
|
146
119
|
output,
|
|
147
120
|
targets,
|
|
@@ -153,14 +126,11 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
153
126
|
'react-native': _path.default.join(source, entryFile),
|
|
154
127
|
'source': _path.default.join(source, entryFile)
|
|
155
128
|
};
|
|
156
|
-
|
|
157
129
|
if (targets.includes('module')) {
|
|
158
130
|
entries.module = _path.default.join(output, 'module', 'index.js');
|
|
159
131
|
}
|
|
160
|
-
|
|
161
132
|
if (targets.includes('typescript')) {
|
|
162
133
|
entries.types = _path.default.join(output, 'typescript', source, 'index.d.ts');
|
|
163
|
-
|
|
164
134
|
if (!(await _fsExtra.default.pathExists(_path.default.join(root, 'tsconfig.json')))) {
|
|
165
135
|
const {
|
|
166
136
|
tsconfig
|
|
@@ -170,9 +140,8 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
170
140
|
message: `You have enabled 'typescript' compilation, but we couldn't find a 'tsconfig.json' in project root. Generate one?`,
|
|
171
141
|
initial: true
|
|
172
142
|
});
|
|
173
|
-
|
|
174
143
|
if (tsconfig) {
|
|
175
|
-
await _fsExtra.default.
|
|
144
|
+
await _fsExtra.default.writeJSON(_path.default.join(root, 'tsconfig.json'), {
|
|
176
145
|
compilerOptions: {
|
|
177
146
|
rootDir: '.',
|
|
178
147
|
allowUnreachableCode: false,
|
|
@@ -196,17 +165,16 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
196
165
|
target: 'esnext',
|
|
197
166
|
verbatimModuleSyntax: true
|
|
198
167
|
}
|
|
199
|
-
},
|
|
168
|
+
}, {
|
|
169
|
+
spaces: 2
|
|
170
|
+
});
|
|
200
171
|
}
|
|
201
172
|
}
|
|
202
173
|
}
|
|
203
|
-
|
|
204
|
-
const prepack = 'bob build';
|
|
174
|
+
const prepare = 'bob build';
|
|
205
175
|
const files = [source, output, '!**/__tests__', '!**/__fixtures__', '!**/__mocks__'];
|
|
206
|
-
|
|
207
176
|
for (const key in entries) {
|
|
208
177
|
const entry = entries[key];
|
|
209
|
-
|
|
210
178
|
if (pkg[key] && pkg[key] !== entry) {
|
|
211
179
|
const {
|
|
212
180
|
replace
|
|
@@ -216,7 +184,6 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
216
184
|
message: `Your package.json has the '${key}' field set to '${pkg[key]}'. Do you want to replace it with '${entry}'?`,
|
|
217
185
|
initial: true
|
|
218
186
|
});
|
|
219
|
-
|
|
220
187
|
if (replace) {
|
|
221
188
|
pkg[key] = entry;
|
|
222
189
|
}
|
|
@@ -224,25 +191,22 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
224
191
|
pkg[key] = entry;
|
|
225
192
|
}
|
|
226
193
|
}
|
|
227
|
-
|
|
228
|
-
if (pkg.scripts?.prepack && pkg.scripts.prepack !== prepack) {
|
|
194
|
+
if (pkg.scripts?.prepare && pkg.scripts.prepare !== prepare) {
|
|
229
195
|
const {
|
|
230
196
|
replace
|
|
231
197
|
} = await (0, _prompts.default)({
|
|
232
198
|
type: 'confirm',
|
|
233
199
|
name: 'replace',
|
|
234
|
-
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}'?`,
|
|
235
201
|
initial: true
|
|
236
202
|
});
|
|
237
|
-
|
|
238
203
|
if (replace) {
|
|
239
|
-
pkg.scripts.
|
|
204
|
+
pkg.scripts.prepare = prepare;
|
|
240
205
|
}
|
|
241
206
|
} else {
|
|
242
207
|
pkg.scripts = pkg.scripts || {};
|
|
243
|
-
pkg.scripts.
|
|
208
|
+
pkg.scripts.prepare = prepare;
|
|
244
209
|
}
|
|
245
|
-
|
|
246
210
|
if (pkg.files && JSON.stringify(pkg.files.slice().sort()) !== JSON.stringify(files.slice().sort())) {
|
|
247
211
|
const {
|
|
248
212
|
update
|
|
@@ -252,14 +216,12 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
252
216
|
message: `Your package.json already has a 'files' field. Do you want to update it?`,
|
|
253
217
|
initial: true
|
|
254
218
|
});
|
|
255
|
-
|
|
256
219
|
if (update) {
|
|
257
220
|
pkg.files = [...files, ...pkg.files.filter(file => !files.includes(file.replace(/\/$/g, '')))];
|
|
258
221
|
}
|
|
259
222
|
} else {
|
|
260
223
|
pkg.files = files;
|
|
261
224
|
}
|
|
262
|
-
|
|
263
225
|
pkg[name] = {
|
|
264
226
|
source,
|
|
265
227
|
output,
|
|
@@ -269,19 +231,15 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
269
231
|
copyFlow: true
|
|
270
232
|
}];
|
|
271
233
|
}
|
|
272
|
-
|
|
273
234
|
return t;
|
|
274
235
|
})
|
|
275
236
|
};
|
|
276
|
-
|
|
277
237
|
if (pkg.jest) {
|
|
278
238
|
const entry = `<rootDir>/${output}/`;
|
|
279
|
-
|
|
280
239
|
if (pkg.jest.modulePathIgnorePatterns) {
|
|
281
240
|
const {
|
|
282
241
|
modulePathIgnorePatterns
|
|
283
242
|
} = pkg.jest;
|
|
284
|
-
|
|
285
243
|
if (!modulePathIgnorePatterns.includes(entry)) {
|
|
286
244
|
modulePathIgnorePatterns.push(entry);
|
|
287
245
|
}
|
|
@@ -289,26 +247,22 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
289
247
|
pkg.jest.modulePathIgnorePatterns = [entry];
|
|
290
248
|
}
|
|
291
249
|
}
|
|
292
|
-
|
|
293
250
|
pkg.eslintIgnore = pkg.eslintIgnore || ['node_modules/'];
|
|
294
|
-
|
|
295
251
|
if (!pkg.eslintIgnore.includes(`${output}/`)) {
|
|
296
252
|
pkg.eslintIgnore.push(`${output}/`);
|
|
297
253
|
}
|
|
298
|
-
|
|
299
|
-
|
|
254
|
+
await _fsExtra.default.writeJSON(pak, pkg, {
|
|
255
|
+
spaces: 2
|
|
256
|
+
});
|
|
300
257
|
const ignorefiles = [_path.default.join(root, '.gitignore'), _path.default.join(root, '.eslintignore')];
|
|
301
|
-
|
|
302
258
|
for (const ignorefile of ignorefiles) {
|
|
303
259
|
if (await _fsExtra.default.pathExists(ignorefile)) {
|
|
304
260
|
const content = await _fsExtra.default.readFile(ignorefile, 'utf-8');
|
|
305
|
-
|
|
306
261
|
if (!content.split('\n').includes(`${output}/`)) {
|
|
307
262
|
await _fsExtra.default.writeFile(ignorefile, `${content}\n# generated by bob\n${output}/\n`);
|
|
308
263
|
}
|
|
309
264
|
}
|
|
310
265
|
}
|
|
311
|
-
|
|
312
266
|
console.log((0, _dedent.default)(`
|
|
313
267
|
Project ${_kleur.default.yellow(pkg.name)} configured successfully!
|
|
314
268
|
|
|
@@ -320,29 +274,21 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
320
274
|
`));
|
|
321
275
|
}).command('build', 'build files for publishing', {}, async argv => {
|
|
322
276
|
const result = explorer.search();
|
|
323
|
-
|
|
324
277
|
if (!result?.config) {
|
|
325
278
|
logger.exit(`No configuration found. Run '${argv.$0} init' to create one automatically.`);
|
|
326
279
|
}
|
|
327
|
-
|
|
328
280
|
const options = result.config;
|
|
329
|
-
|
|
330
281
|
if (!options.targets?.length) {
|
|
331
282
|
logger.exit(`No targets found in the configuration in '${_path.default.relative(root, result.filepath)}'.`);
|
|
332
283
|
}
|
|
333
|
-
|
|
334
284
|
const source = options.source;
|
|
335
|
-
|
|
336
285
|
if (!source) {
|
|
337
286
|
logger.exit(`No source option found in the configuration in '${_path.default.relative(root, result.filepath)}'.`);
|
|
338
287
|
}
|
|
339
|
-
|
|
340
288
|
const output = options.output;
|
|
341
|
-
|
|
342
289
|
if (!output) {
|
|
343
290
|
logger.exit(`No source option found in the configuration in '${_path.default.relative(root, result.filepath)}'.`);
|
|
344
291
|
}
|
|
345
|
-
|
|
346
292
|
const exclude = options.exclude ?? '**/{__tests__,__fixtures__,__mocks__}/**';
|
|
347
293
|
const report = {
|
|
348
294
|
info: logger.info,
|
|
@@ -350,12 +296,10 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
350
296
|
error: logger.error,
|
|
351
297
|
success: logger.success
|
|
352
298
|
};
|
|
353
|
-
|
|
354
299
|
for (const target of options.targets) {
|
|
355
300
|
const targetName = Array.isArray(target) ? target[0] : target;
|
|
356
301
|
const targetOptions = Array.isArray(target) ? target[1] : undefined;
|
|
357
302
|
report.info(`Building target ${_kleur.default.blue(targetName)}`);
|
|
358
|
-
|
|
359
303
|
switch (targetName) {
|
|
360
304
|
case 'commonjs':
|
|
361
305
|
await (0, _commonjs.default)({
|
|
@@ -367,7 +311,6 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
367
311
|
report
|
|
368
312
|
});
|
|
369
313
|
break;
|
|
370
|
-
|
|
371
314
|
case 'module':
|
|
372
315
|
await (0, _module.default)({
|
|
373
316
|
root,
|
|
@@ -378,7 +321,6 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
378
321
|
report
|
|
379
322
|
});
|
|
380
323
|
break;
|
|
381
|
-
|
|
382
324
|
case 'typescript':
|
|
383
325
|
await (0, _typescript.default)({
|
|
384
326
|
root,
|
|
@@ -388,7 +330,6 @@ _yargs.default.command('init', 'configure the package to use bob', {}, async ()
|
|
|
388
330
|
report
|
|
389
331
|
});
|
|
390
332
|
break;
|
|
391
|
-
|
|
392
333
|
default:
|
|
393
334
|
logger.exit(`Invalid target ${_kleur.default.blue(targetName)}.`);
|
|
394
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","rootDir","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","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.writeFile(\n path.join(root, 'tsconfig.json'),\n JSON.stringify(\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 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 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;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAGA;AACA,MAAM;EAAEA,IAAF;EAAQC;AAAR,IAAoBC,OAAO,CAAC,iBAAD,CAAjC;;AAEA,MAAMC,IAAI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AahI,IAAb,EAAmB8B,MAAnB,CAFY;UAGpBuB,MAAM,EAAEpC,aAAA,CAAK+G,OAAL,CAAahI,IAAb,EAAmBqD,MAAnB,EAAqC,YAArC,CAHY;UAIpB4D,OAAO,EAAEY,aAJW;UAKpBR;QALoB,CAAhB,CAAN;QAOA;;MACF;QACEhG,MAAM,CAACN,IAAP,CAAa,kBAAiB2F,cAAA,CAAMoB,IAAN,CAAWJ,UAAX,CAAuB,GAArD;IA/BJ;EAiCD;AACF,CA3ZH,EA4ZGS,aA5ZH,GA6ZGC,iBA7ZH,GA8ZGnD,MA9ZH,GA8ZY8B,IA9ZZ"}
|
|
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,OA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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,17 +4,11 @@ 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,
|
|
@@ -25,7 +19,8 @@ async function build({
|
|
|
25
19
|
}) {
|
|
26
20
|
report.info(`Cleaning up previous build at ${_kleur.default.blue(_path.default.relative(root, output))}`);
|
|
27
21
|
await (0, _del.default)([output]);
|
|
28
|
-
await (0, _compile.default)({
|
|
22
|
+
await (0, _compile.default)({
|
|
23
|
+
...options,
|
|
29
24
|
root,
|
|
30
25
|
source,
|
|
31
26
|
output,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commonjs.js","names":["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":"
|
|
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,17 +4,11 @@ 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,
|
|
@@ -25,7 +19,8 @@ async function build({
|
|
|
25
19
|
}) {
|
|
26
20
|
report.info(`Cleaning up previous build at ${_kleur.default.blue(_path.default.relative(root, output))}`);
|
|
27
21
|
await (0, _del.default)([output]);
|
|
28
|
-
await (0, _compile.default)({
|
|
22
|
+
await (0, _compile.default)({
|
|
23
|
+
...options,
|
|
29
24
|
root,
|
|
30
25
|
source,
|
|
31
26
|
output,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","names":["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":"
|
|
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"}
|
|
@@ -4,25 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = build;
|
|
7
|
-
|
|
8
7
|
var _kleur = _interopRequireDefault(require("kleur"));
|
|
9
|
-
|
|
10
8
|
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
|
|
12
9
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
13
|
-
|
|
14
10
|
var _which = _interopRequireDefault(require("which"));
|
|
15
|
-
|
|
16
11
|
var _crossSpawn = _interopRequireDefault(require("cross-spawn"));
|
|
17
|
-
|
|
18
12
|
var _del = _interopRequireDefault(require("del"));
|
|
19
|
-
|
|
20
13
|
var _json = _interopRequireDefault(require("json5"));
|
|
21
|
-
|
|
22
14
|
var _os = require("os");
|
|
23
|
-
|
|
24
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
16
|
async function build({
|
|
27
17
|
source,
|
|
28
18
|
root,
|
|
@@ -34,33 +24,25 @@ async function build({
|
|
|
34
24
|
await (0, _del.default)([output]);
|
|
35
25
|
report.info(`Generating type definitions with ${_kleur.default.blue('tsc')}`);
|
|
36
26
|
const project = options?.project ? options.project : 'tsconfig.json';
|
|
37
|
-
|
|
38
27
|
const tsconfig = _path.default.join(root, project);
|
|
39
|
-
|
|
40
28
|
try {
|
|
41
29
|
if (await _fsExtra.default.pathExists(tsconfig)) {
|
|
42
30
|
try {
|
|
43
31
|
const config = _json.default.parse(await _fsExtra.default.readFile(tsconfig, 'utf-8'));
|
|
44
|
-
|
|
45
32
|
if (config.compilerOptions) {
|
|
46
33
|
const conflicts = [];
|
|
47
|
-
|
|
48
34
|
if (config.compilerOptions.noEmit !== undefined) {
|
|
49
35
|
conflicts.push('compilerOptions.noEmit');
|
|
50
36
|
}
|
|
51
|
-
|
|
52
37
|
if (config.compilerOptions.emitDeclarationOnly !== undefined) {
|
|
53
38
|
conflicts.push('compilerOptions.emitDeclarationOnly');
|
|
54
39
|
}
|
|
55
|
-
|
|
56
40
|
if (config.compilerOptions.declarationDir) {
|
|
57
41
|
conflicts.push('compilerOptions.declarationDir');
|
|
58
42
|
}
|
|
59
|
-
|
|
60
43
|
if (config.compilerOptions.outDir && _path.default.join(root, config.compilerOptions.outDir) !== output) {
|
|
61
44
|
conflicts.push('compilerOptions.outDir');
|
|
62
45
|
}
|
|
63
|
-
|
|
64
46
|
if (conflicts.length) {
|
|
65
47
|
report.warn(`Found following options in the config file which can conflict with the CLI options. Please remove them from ${_kleur.default.blue(project)}:${conflicts.reduce((acc, curr) => acc + `\n${_kleur.default.gray('-')} ${_kleur.default.yellow(curr)}`, '')}`);
|
|
66
48
|
}
|
|
@@ -71,93 +53,75 @@ async function build({
|
|
|
71
53
|
} else {
|
|
72
54
|
throw new Error(`Couldn't find a ${_kleur.default.blue('tsconfig.json')} in the project root.`);
|
|
73
55
|
}
|
|
74
|
-
|
|
75
56
|
let tsc;
|
|
76
|
-
|
|
77
57
|
if (options?.tsc) {
|
|
78
58
|
tsc = _path.default.resolve(root, options.tsc);
|
|
79
|
-
|
|
80
59
|
if (!(await _fsExtra.default.pathExists(tsc))) {
|
|
81
60
|
throw new Error(`The ${_kleur.default.blue('tsc')} binary doesn't seem to be installed at ${_kleur.default.blue(tsc)}. Please specify the correct path in options or remove it to use the workspace's version.`);
|
|
82
61
|
}
|
|
83
62
|
} else {
|
|
84
63
|
const execpath = process.env.npm_execpath;
|
|
85
64
|
const cli = execpath?.split('/').pop()?.includes('yarn') ? 'yarn' : 'npm';
|
|
86
|
-
|
|
87
65
|
if (cli === 'yarn') {
|
|
88
66
|
const result = _crossSpawn.default.sync('yarn', ['bin', 'tsc'], {
|
|
89
67
|
stdio: 'pipe',
|
|
90
68
|
encoding: 'utf-8',
|
|
91
69
|
cwd: root
|
|
92
70
|
});
|
|
93
|
-
|
|
94
71
|
tsc = result.stdout.trim();
|
|
95
72
|
} else {
|
|
96
73
|
tsc = _path.default.resolve(root, 'node_modules', '.bin', 'tsc');
|
|
97
74
|
}
|
|
98
|
-
|
|
99
75
|
if ((0, _os.platform)() === 'win32' && !tsc.endsWith('.cmd')) {
|
|
100
76
|
tsc += '.cmd';
|
|
101
77
|
}
|
|
102
78
|
}
|
|
103
|
-
|
|
104
79
|
if (!(await _fsExtra.default.pathExists(tsc))) {
|
|
105
80
|
try {
|
|
106
81
|
tsc = await (0, _which.default)('tsc');
|
|
107
|
-
|
|
108
82
|
if (await _fsExtra.default.pathExists(tsc)) {
|
|
109
83
|
report.warn(`Failed to locate ${_kleur.default.blue('tsc')} in the workspace. Falling back to the binary found in ${_kleur.default.blue('PATH')} at ${_kleur.default.blue(tsc)}. Consider adding ${_kleur.default.blue('typescript')} to your ${_kleur.default.blue('devDependencies')} or specifying the ${_kleur.default.blue('tsc')} option for the typescript target.`);
|
|
110
84
|
}
|
|
111
|
-
} catch (e) {
|
|
85
|
+
} catch (e) {
|
|
86
|
+
// Ignore
|
|
112
87
|
}
|
|
113
88
|
}
|
|
114
|
-
|
|
115
89
|
if (tsc == null || !(await _fsExtra.default.pathExists(tsc))) {
|
|
116
90
|
throw new Error(`The ${_kleur.default.blue('tsc')} binary doesn't seem to be installed under ${_kleur.default.blue('node_modules')} or present in $PATH. Make sure you have added ${_kleur.default.blue('typescript')} to your ${_kleur.default.blue('devDependencies')} or specify the ${_kleur.default.blue('tsc')} option for typescript.`);
|
|
117
91
|
}
|
|
118
|
-
|
|
119
92
|
const tsbuildinfo = _path.default.join(output, project.replace(/\.json$/, '.tsbuildinfo'));
|
|
120
|
-
|
|
121
93
|
try {
|
|
122
94
|
await (0, _del.default)([tsbuildinfo]);
|
|
123
|
-
} catch (e) {
|
|
95
|
+
} catch (e) {
|
|
96
|
+
// Ignore
|
|
124
97
|
}
|
|
125
|
-
|
|
126
98
|
const result = _crossSpawn.default.sync(tsc, ['--pretty', '--declaration', '--declarationMap', '--emitDeclarationOnly', '--project', project, '--outDir', output], {
|
|
127
99
|
stdio: 'inherit',
|
|
128
100
|
cwd: root
|
|
129
101
|
});
|
|
130
|
-
|
|
131
102
|
if (result.status === 0) {
|
|
132
103
|
await (0, _del.default)([tsbuildinfo]);
|
|
133
104
|
report.success(`Wrote definition files to ${_kleur.default.blue(_path.default.relative(root, output))}`);
|
|
134
105
|
const pkg = JSON.parse(await _fsExtra.default.readFile(_path.default.join(root, 'package.json'), 'utf-8'));
|
|
135
|
-
|
|
136
106
|
const getGeneratedTypesPath = async () => {
|
|
137
107
|
if (pkg.source) {
|
|
138
108
|
const indexDTsName = _path.default.basename(pkg.source).replace(/\.(jsx?|tsx?)$/, '') + '.d.ts';
|
|
139
109
|
const potentialPaths = [_path.default.join(output, _path.default.dirname(pkg.source), indexDTsName), _path.default.join(output, _path.default.dirname(_path.default.relative(source, _path.default.join(root, pkg.source))), indexDTsName)];
|
|
140
|
-
|
|
141
110
|
for (const potentialPath of potentialPaths) {
|
|
142
111
|
if (await _fsExtra.default.pathExists(potentialPath)) {
|
|
143
112
|
return _path.default.relative(root, potentialPath);
|
|
144
113
|
}
|
|
145
114
|
}
|
|
146
115
|
}
|
|
147
|
-
|
|
148
116
|
return null;
|
|
149
117
|
};
|
|
150
|
-
|
|
151
118
|
if ('types' in pkg) {
|
|
152
119
|
const typesPath = _path.default.join(root, pkg.types);
|
|
153
|
-
|
|
154
120
|
if (!(await _fsExtra.default.pathExists(typesPath))) {
|
|
155
121
|
const generatedTypesPath = await getGeneratedTypesPath();
|
|
156
|
-
|
|
157
122
|
if (!generatedTypesPath) {
|
|
158
123
|
report.warn(`Failed to detect the entry point for the generated types. Make sure you have a valid ${_kleur.default.blue('source')} field in your ${_kleur.default.blue('package.json')}.`);
|
|
159
124
|
}
|
|
160
|
-
|
|
161
125
|
report.error(`The ${_kleur.default.blue('types')} field in ${_kleur.default.blue('package.json')} points to a non-existent file: ${_kleur.default.blue(pkg.types)}.\nVerify the path points to the correct file under ${_kleur.default.blue(_path.default.relative(root, output))}${generatedTypesPath ? ` (found ${_kleur.default.blue(generatedTypesPath)}).` : '.'}`);
|
|
162
126
|
throw new Error("Found incorrect path in 'types' field.");
|
|
163
127
|
}
|
|
@@ -180,7 +144,6 @@ async function build({
|
|
|
180
144
|
} else {
|
|
181
145
|
throw e;
|
|
182
146
|
}
|
|
183
|
-
|
|
184
147
|
throw new Error('Failed to build definition files.');
|
|
185
148
|
}
|
|
186
149
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.js","names":["build","source","root","output","report","options","info","kleur","blue","path","relative","del","project","tsconfig","join","fs","pathExists","config","JSON5","parse","readFile","compilerOptions","conflicts","noEmit","undefined","push","emitDeclarationOnly","declarationDir","outDir","length","warn","reduce","acc","curr","gray","yellow","e","Error","tsc","resolve","execpath","process","env","npm_execpath","cli","split","pop","includes","result","spawn","sync","stdio","encoding","cwd","stdout","trim","platform","endsWith","which","tsbuildinfo","replace","status","success","pkg","JSON","getGeneratedTypesPath","indexDTsName","basename","potentialPaths","dirname","potentialPath","typesPath","types","generatedTypesPath","error","toString","message"],"sources":["../../src/targets/typescript.ts"],"sourcesContent":["import kleur from 'kleur';\nimport path from 'path';\nimport fs from 'fs-extra';\nimport which from 'which';\nimport spawn from 'cross-spawn';\nimport del from 'del';\nimport JSON5 from 'json5';\nimport { platform } from 'os';\nimport type { Input } from '../types';\n\ntype Options = Input & {\n options?: { project?: string; tsc?: string };\n};\n\nexport default async function build({\n source,\n root,\n output,\n report,\n options,\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 report.info(`Generating type definitions with ${kleur.blue('tsc')}`);\n\n const project = options?.project ? options.project : 'tsconfig.json';\n const tsconfig = path.join(root, project);\n\n try {\n if (await fs.pathExists(tsconfig)) {\n try {\n const config = JSON5.parse(await fs.readFile(tsconfig, 'utf-8'));\n\n if (config.compilerOptions) {\n const conflicts: string[] = [];\n\n if (config.compilerOptions.noEmit !== undefined) {\n conflicts.push('compilerOptions.noEmit');\n }\n\n if (config.compilerOptions.emitDeclarationOnly !== undefined) {\n conflicts.push('compilerOptions.emitDeclarationOnly');\n }\n\n if (config.compilerOptions.declarationDir) {\n conflicts.push('compilerOptions.declarationDir');\n }\n\n if (\n config.compilerOptions.outDir &&\n path.join(root, config.compilerOptions.outDir) !== output\n ) {\n conflicts.push('compilerOptions.outDir');\n }\n\n if (conflicts.length) {\n report.warn(\n `Found following options in the config file which can conflict with the CLI options. Please remove them from ${kleur.blue(\n project\n )}:${conflicts.reduce(\n (acc, curr) =>\n acc + `\\n${kleur.gray('-')} ${kleur.yellow(curr)}`,\n ''\n )}`\n );\n }\n }\n } catch (e) {\n report.warn(\n `Couldn't parse '${project}'. There might be validation errors.`\n );\n }\n } else {\n throw new Error(\n `Couldn't find a ${kleur.blue('tsconfig.json')} in the project root.`\n );\n }\n\n let tsc;\n\n if (options?.tsc) {\n tsc = path.resolve(root, options.tsc);\n\n if (!(await fs.pathExists(tsc))) {\n throw new Error(\n `The ${kleur.blue(\n 'tsc'\n )} binary doesn't seem to be installed at ${kleur.blue(\n tsc\n )}. Please specify the correct path in options or remove it to use the workspace's version.`\n );\n }\n } else {\n const execpath = process.env.npm_execpath;\n const cli = execpath?.split('/').pop()?.includes('yarn') ? 'yarn' : 'npm';\n\n if (cli === 'yarn') {\n const result = spawn.sync('yarn', ['bin', 'tsc'], {\n stdio: 'pipe',\n encoding: 'utf-8',\n cwd: root,\n });\n\n tsc = result.stdout.trim();\n } else {\n tsc = path.resolve(root, 'node_modules', '.bin', 'tsc');\n }\n\n if (platform() === 'win32' && !tsc.endsWith('.cmd')) {\n tsc += '.cmd';\n }\n }\n\n if (!(await fs.pathExists(tsc))) {\n try {\n tsc = await which('tsc');\n\n if (await fs.pathExists(tsc)) {\n report.warn(\n `Failed to locate ${kleur.blue(\n 'tsc'\n )} in the workspace. Falling back to the binary found in ${kleur.blue(\n 'PATH'\n )} at ${kleur.blue(tsc)}. Consider adding ${kleur.blue(\n 'typescript'\n )} to your ${kleur.blue(\n 'devDependencies'\n )} or specifying the ${kleur.blue(\n 'tsc'\n )} option for the typescript target.`\n );\n }\n } catch (e) {\n // Ignore\n }\n }\n\n if (tsc == null || !(await fs.pathExists(tsc))) {\n throw new Error(\n `The ${kleur.blue(\n 'tsc'\n )} binary doesn't seem to be installed under ${kleur.blue(\n 'node_modules'\n )} or present in $PATH. Make sure you have added ${kleur.blue(\n 'typescript'\n )} to your ${kleur.blue('devDependencies')} or specify the ${kleur.blue(\n 'tsc'\n )} option for typescript.`\n );\n }\n\n const tsbuildinfo = path.join(\n output,\n project.replace(/\\.json$/, '.tsbuildinfo')\n );\n\n try {\n await del([tsbuildinfo]);\n } catch (e) {\n // Ignore\n }\n\n const result = spawn.sync(\n tsc,\n [\n '--pretty',\n '--declaration',\n '--declarationMap',\n '--emitDeclarationOnly',\n '--project',\n project,\n '--outDir',\n output,\n ],\n {\n stdio: 'inherit',\n cwd: root,\n }\n );\n\n if (result.status === 0) {\n await del([tsbuildinfo]);\n\n report.success(\n `Wrote definition files to ${kleur.blue(path.relative(root, output))}`\n );\n\n const pkg = JSON.parse(\n await fs.readFile(path.join(root, 'package.json'), 'utf-8')\n );\n\n const getGeneratedTypesPath = async () => {\n if (pkg.source) {\n const indexDTsName =\n path.basename(pkg.source).replace(/\\.(jsx?|tsx?)$/, '') + '.d.ts';\n\n const potentialPaths = [\n path.join(output, path.dirname(pkg.source), indexDTsName),\n path.join(\n output,\n path.dirname(path.relative(source, path.join(root, pkg.source))),\n indexDTsName\n ),\n ];\n\n for (const potentialPath of potentialPaths) {\n if (await fs.pathExists(potentialPath)) {\n return path.relative(root, potentialPath);\n }\n }\n }\n\n return null;\n };\n\n if ('types' in pkg) {\n const typesPath = path.join(root, pkg.types);\n\n if (!(await fs.pathExists(typesPath))) {\n const generatedTypesPath = await getGeneratedTypesPath();\n\n if (!generatedTypesPath) {\n report.warn(\n `Failed to detect the entry point for the generated types. Make sure you have a valid ${kleur.blue(\n 'source'\n )} field in your ${kleur.blue('package.json')}.`\n );\n }\n\n report.error(\n `The ${kleur.blue('types')} field in ${kleur.blue(\n 'package.json'\n )} points to a non-existent file: ${kleur.blue(\n pkg.types\n )}.\\nVerify the path points to the correct file under ${kleur.blue(\n path.relative(root, output)\n )}${\n generatedTypesPath\n ? ` (found ${kleur.blue(generatedTypesPath)}).`\n : '.'\n }`\n );\n\n throw new Error(\"Found incorrect path in 'types' field.\");\n }\n } else {\n const generatedTypesPath = await getGeneratedTypesPath();\n\n report.warn(\n `No ${kleur.blue('types')} field found in ${kleur.blue(\n 'package.json'\n )}.\\nConsider ${\n generatedTypesPath\n ? `pointing it to ${kleur.blue(generatedTypesPath)}`\n : 'adding it'\n } so that consumers of your package can use the types.`\n );\n }\n } else {\n throw new Error('Failed to build definition files.');\n }\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 when building definition files:\\n${e.stdout.toString()}`\n );\n } else if ('message' in e && typeof e.message === 'string') {\n report.error(e.message);\n } else {\n throw e;\n }\n } else {\n throw e;\n }\n\n throw new Error('Failed to build definition files.');\n }\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;AAOe,eAAeA,KAAf,CAAqB;EAClCC,MADkC;EAElCC,IAFkC;EAGlCC,MAHkC;EAIlCC,MAJkC;EAKlCC;AALkC,CAArB,EAMH;EACVD,MAAM,CAACE,IAAP,CACG,iCAAgCC,cAAA,CAAMC,IAAN,CAAWC,aAAA,CAAKC,QAAL,CAAcR,IAAd,EAAoBC,MAApB,CAAX,CAAwC,EAD3E;EAIA,MAAM,IAAAQ,YAAA,EAAI,CAACR,MAAD,CAAJ,CAAN;EAEAC,MAAM,CAACE,IAAP,CAAa,oCAAmCC,cAAA,CAAMC,IAAN,CAAW,KAAX,CAAkB,EAAlE;EAEA,MAAMI,OAAO,GAAGP,OAAO,EAAEO,OAAT,GAAmBP,OAAO,CAACO,OAA3B,GAAqC,eAArD;;EACA,MAAMC,QAAQ,GAAGJ,aAAA,CAAKK,IAAL,CAAUZ,IAAV,EAAgBU,OAAhB,CAAjB;;EAEA,IAAI;IACF,IAAI,MAAMG,gBAAA,CAAGC,UAAH,CAAcH,QAAd,CAAV,EAAmC;MACjC,IAAI;QACF,MAAMI,MAAM,GAAGC,aAAA,CAAMC,KAAN,CAAY,MAAMJ,gBAAA,CAAGK,QAAH,CAAYP,QAAZ,EAAsB,OAAtB,CAAlB,CAAf;;QAEA,IAAII,MAAM,CAACI,eAAX,EAA4B;UAC1B,MAAMC,SAAmB,GAAG,EAA5B;;UAEA,IAAIL,MAAM,CAACI,eAAP,CAAuBE,MAAv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,CAAU,mCAAV,CAAN;IACD;EACF,CAzOD,CAyOE,OAAOD,CAAP,EAAmB;IACnB,IAAIA,CAAC,IAAI,IAAL,IAAa,OAAOA,CAAP,KAAa,QAA9B,EAAwC;MACtC,IAAI,YAAYA,CAAZ,IAAiBA,CAAC,CAACkB,MAAF,IAAY,IAAjC,EAAuC;QACrClD,MAAM,CAACsE,KAAP,CACG,iDAAgDtC,CAAC,CAACkB,MAAF,CAASqB,QAAT,EAAoB,EADvE;MAGD,CAJD,MAIO,IAAI,aAAavC,CAAb,IAAkB,OAAOA,CAAC,CAACwC,OAAT,KAAqB,QAA3C,EAAqD;QAC1DxE,MAAM,CAACsE,KAAP,CAAatC,CAAC,CAACwC,OAAf;MACD,CAFM,MAEA;QACL,MAAMxC,CAAN;MACD;IACF,CAVD,MAUO;MACL,MAAMA,CAAN;IACD;;IAED,MAAM,IAAIC,KAAJ,CAAU,mCAAV,CAAN;EACD;AACF"}
|
|
1
|
+
{"version":3,"file":"typescript.js","names":["_kleur","_interopRequireDefault","require","_path","_fsExtra","_which","_crossSpawn","_del","_json","_os","obj","__esModule","default","build","source","root","output","report","options","info","kleur","blue","path","relative","del","project","tsconfig","join","fs","pathExists","config","JSON5","parse","readFile","compilerOptions","conflicts","noEmit","undefined","push","emitDeclarationOnly","declarationDir","outDir","length","warn","reduce","acc","curr","gray","yellow","e","Error","tsc","resolve","execpath","process","env","npm_execpath","cli","split","pop","includes","result","spawn","sync","stdio","encoding","cwd","stdout","trim","platform","endsWith","which","tsbuildinfo","replace","status","success","pkg","JSON","getGeneratedTypesPath","indexDTsName","basename","potentialPaths","dirname","potentialPath","typesPath","types","generatedTypesPath","error","toString","message"],"sources":["../../src/targets/typescript.ts"],"sourcesContent":["import kleur from 'kleur';\nimport path from 'path';\nimport fs from 'fs-extra';\nimport which from 'which';\nimport spawn from 'cross-spawn';\nimport del from 'del';\nimport JSON5 from 'json5';\nimport { platform } from 'os';\nimport type { Input } from '../types';\n\ntype Options = Input & {\n options?: { project?: string; tsc?: string };\n};\n\nexport default async function build({\n source,\n root,\n output,\n report,\n options,\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 report.info(`Generating type definitions with ${kleur.blue('tsc')}`);\n\n const project = options?.project ? options.project : 'tsconfig.json';\n const tsconfig = path.join(root, project);\n\n try {\n if (await fs.pathExists(tsconfig)) {\n try {\n const config = JSON5.parse(await fs.readFile(tsconfig, 'utf-8'));\n\n if (config.compilerOptions) {\n const conflicts: string[] = [];\n\n if (config.compilerOptions.noEmit !== undefined) {\n conflicts.push('compilerOptions.noEmit');\n }\n\n if (config.compilerOptions.emitDeclarationOnly !== undefined) {\n conflicts.push('compilerOptions.emitDeclarationOnly');\n }\n\n if (config.compilerOptions.declarationDir) {\n conflicts.push('compilerOptions.declarationDir');\n }\n\n if (\n config.compilerOptions.outDir &&\n path.join(root, config.compilerOptions.outDir) !== output\n ) {\n conflicts.push('compilerOptions.outDir');\n }\n\n if (conflicts.length) {\n report.warn(\n `Found following options in the config file which can conflict with the CLI options. Please remove them from ${kleur.blue(\n project\n )}:${conflicts.reduce(\n (acc, curr) =>\n acc + `\\n${kleur.gray('-')} ${kleur.yellow(curr)}`,\n ''\n )}`\n );\n }\n }\n } catch (e) {\n report.warn(\n `Couldn't parse '${project}'. There might be validation errors.`\n );\n }\n } else {\n throw new Error(\n `Couldn't find a ${kleur.blue('tsconfig.json')} in the project root.`\n );\n }\n\n let tsc;\n\n if (options?.tsc) {\n tsc = path.resolve(root, options.tsc);\n\n if (!(await fs.pathExists(tsc))) {\n throw new Error(\n `The ${kleur.blue(\n 'tsc'\n )} binary doesn't seem to be installed at ${kleur.blue(\n tsc\n )}. Please specify the correct path in options or remove it to use the workspace's version.`\n );\n }\n } else {\n const execpath = process.env.npm_execpath;\n const cli = execpath?.split('/').pop()?.includes('yarn') ? 'yarn' : 'npm';\n\n if (cli === 'yarn') {\n const result = spawn.sync('yarn', ['bin', 'tsc'], {\n stdio: 'pipe',\n encoding: 'utf-8',\n cwd: root,\n });\n\n tsc = result.stdout.trim();\n } else {\n tsc = path.resolve(root, 'node_modules', '.bin', 'tsc');\n }\n\n if (platform() === 'win32' && !tsc.endsWith('.cmd')) {\n tsc += '.cmd';\n }\n }\n\n if (!(await fs.pathExists(tsc))) {\n try {\n tsc = await which('tsc');\n\n if (await fs.pathExists(tsc)) {\n report.warn(\n `Failed to locate ${kleur.blue(\n 'tsc'\n )} in the workspace. Falling back to the binary found in ${kleur.blue(\n 'PATH'\n )} at ${kleur.blue(tsc)}. Consider adding ${kleur.blue(\n 'typescript'\n )} to your ${kleur.blue(\n 'devDependencies'\n )} or specifying the ${kleur.blue(\n 'tsc'\n )} option for the typescript target.`\n );\n }\n } catch (e) {\n // Ignore\n }\n }\n\n if (tsc == null || !(await fs.pathExists(tsc))) {\n throw new Error(\n `The ${kleur.blue(\n 'tsc'\n )} binary doesn't seem to be installed under ${kleur.blue(\n 'node_modules'\n )} or present in $PATH. Make sure you have added ${kleur.blue(\n 'typescript'\n )} to your ${kleur.blue('devDependencies')} or specify the ${kleur.blue(\n 'tsc'\n )} option for typescript.`\n );\n }\n\n const tsbuildinfo = path.join(\n output,\n project.replace(/\\.json$/, '.tsbuildinfo')\n );\n\n try {\n await del([tsbuildinfo]);\n } catch (e) {\n // Ignore\n }\n\n const result = spawn.sync(\n tsc,\n [\n '--pretty',\n '--declaration',\n '--declarationMap',\n '--emitDeclarationOnly',\n '--project',\n project,\n '--outDir',\n output,\n ],\n {\n stdio: 'inherit',\n cwd: root,\n }\n );\n\n if (result.status === 0) {\n await del([tsbuildinfo]);\n\n report.success(\n `Wrote definition files to ${kleur.blue(path.relative(root, output))}`\n );\n\n const pkg = JSON.parse(\n await fs.readFile(path.join(root, 'package.json'), 'utf-8')\n );\n\n const getGeneratedTypesPath = async () => {\n if (pkg.source) {\n const indexDTsName =\n path.basename(pkg.source).replace(/\\.(jsx?|tsx?)$/, '') + '.d.ts';\n\n const potentialPaths = [\n path.join(output, path.dirname(pkg.source), indexDTsName),\n path.join(\n output,\n path.dirname(path.relative(source, path.join(root, pkg.source))),\n indexDTsName\n ),\n ];\n\n for (const potentialPath of potentialPaths) {\n if (await fs.pathExists(potentialPath)) {\n return path.relative(root, potentialPath);\n }\n }\n }\n\n return null;\n };\n\n if ('types' in pkg) {\n const typesPath = path.join(root, pkg.types);\n\n if (!(await fs.pathExists(typesPath))) {\n const generatedTypesPath = await getGeneratedTypesPath();\n\n if (!generatedTypesPath) {\n report.warn(\n `Failed to detect the entry point for the generated types. Make sure you have a valid ${kleur.blue(\n 'source'\n )} field in your ${kleur.blue('package.json')}.`\n );\n }\n\n report.error(\n `The ${kleur.blue('types')} field in ${kleur.blue(\n 'package.json'\n )} points to a non-existent file: ${kleur.blue(\n pkg.types\n )}.\\nVerify the path points to the correct file under ${kleur.blue(\n path.relative(root, output)\n )}${\n generatedTypesPath\n ? ` (found ${kleur.blue(generatedTypesPath)}).`\n : '.'\n }`\n );\n\n throw new Error(\"Found incorrect path in 'types' field.\");\n }\n } else {\n const generatedTypesPath = await getGeneratedTypesPath();\n\n report.warn(\n `No ${kleur.blue('types')} field found in ${kleur.blue(\n 'package.json'\n )}.\\nConsider ${\n generatedTypesPath\n ? `pointing it to ${kleur.blue(generatedTypesPath)}`\n : 'adding it'\n } so that consumers of your package can use the types.`\n );\n }\n } else {\n throw new Error('Failed to build definition files.');\n }\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 when building definition files:\\n${e.stdout.toString()}`\n );\n } else if ('message' in e && typeof e.message === 'string') {\n report.error(e.message);\n } else {\n throw e;\n }\n } else {\n throw e;\n }\n\n throw new Error('Failed to build definition files.');\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAH,sBAAA,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Q,IAAIA,CAAC,IAAIA,CAAC,CAACkB,MAAM,IAAI,IAAI,EAAE;QACrClD,MAAM,CAACsE,KAAK,CACT,iDAAgDtC,CAAC,CAACkB,MAAM,CAACqB,QAAQ,CAAC,CAAE,EACvE,CAAC;MACH,CAAC,MAAM,IAAI,SAAS,IAAIvC,CAAC,IAAI,OAAOA,CAAC,CAACwC,OAAO,KAAK,QAAQ,EAAE;QAC1DxE,MAAM,CAACsE,KAAK,CAACtC,CAAC,CAACwC,OAAO,CAAC;MACzB,CAAC,MAAM;QACL,MAAMxC,CAAC;MACT;IACF,CAAC,MAAM;MACL,MAAMA,CAAC;IACT;IAEA,MAAM,IAAIC,KAAK,CAAC,mCAAmC,CAAC;EACtD;AACF"}
|
|
@@ -4,29 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = androidAssemble;
|
|
7
|
-
|
|
8
7
|
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
8
|
var _kleur = _interopRequireDefault(require("kleur"));
|
|
11
|
-
|
|
12
9
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
13
|
-
|
|
14
10
|
var _child_process = require("child_process");
|
|
15
|
-
|
|
16
11
|
var _os = require("os");
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
13
|
async function androidAssemble({
|
|
21
14
|
root,
|
|
22
15
|
androidPath,
|
|
23
16
|
report
|
|
24
17
|
}) {
|
|
25
18
|
const cwd = _path.default.relative(root, androidPath);
|
|
26
|
-
|
|
27
19
|
report.info(`Assembling Android project in ${_kleur.default.blue(cwd)} with ${_kleur.default.blue('gradle')}`);
|
|
28
20
|
const gradleWrapper = (0, _os.platform)() === 'win32' ? 'gradlew.bat' : './gradlew';
|
|
29
|
-
|
|
30
21
|
if (await _fsExtra.default.pathExists(_path.default.join(androidPath, gradleWrapper))) {
|
|
31
22
|
(0, _child_process.execFileSync)(gradleWrapper, ['assemble'], {
|
|
32
23
|
cwd: androidPath
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"androidAssemble.js","names":["androidAssemble","root","androidPath","report","cwd","path","relative","info","kleur","blue","gradleWrapper","platform","fs","pathExists","join","execFileSync","Error"],"sources":["../../src/utils/androidAssemble.ts"],"sourcesContent":["import path from 'path';\nimport kleur from 'kleur';\nimport fs from 'fs-extra';\nimport { execFileSync } from 'child_process';\nimport { platform } from 'os';\nimport type { Report } from '../types';\n\ntype Options = {\n root: string;\n androidPath: string;\n report: Report;\n};\n\nexport default async function androidAssemble({\n root,\n androidPath,\n report,\n}: Options) {\n const cwd = path.relative(root, androidPath);\n\n report.info(\n `Assembling Android project in ${kleur.blue(cwd)} with ${kleur.blue(\n 'gradle'\n )}`\n );\n\n const gradleWrapper = platform() === 'win32' ? 'gradlew.bat' : './gradlew';\n if (await fs.pathExists(path.join(androidPath, gradleWrapper))) {\n execFileSync(gradleWrapper, ['assemble'], { cwd: androidPath });\n } else {\n throw new Error(\n `The ${kleur.blue(\n 'gradlew'\n )} script doesn't seem to present in ${kleur.blue(\n androidPath\n )}. Make sure you have added it by running ${kleur.blue(\n 'gradle wrapper'\n )} in that directory.`\n );\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"androidAssemble.js","names":["_path","_interopRequireDefault","require","_kleur","_fsExtra","_child_process","_os","obj","__esModule","default","androidAssemble","root","androidPath","report","cwd","path","relative","info","kleur","blue","gradleWrapper","platform","fs","pathExists","join","execFileSync","Error"],"sources":["../../src/utils/androidAssemble.ts"],"sourcesContent":["import path from 'path';\nimport kleur from 'kleur';\nimport fs from 'fs-extra';\nimport { execFileSync } from 'child_process';\nimport { platform } from 'os';\nimport type { Report } from '../types';\n\ntype Options = {\n root: string;\n androidPath: string;\n report: Report;\n};\n\nexport default async function androidAssemble({\n root,\n androidPath,\n report,\n}: Options) {\n const cwd = path.relative(root, androidPath);\n\n report.info(\n `Assembling Android project in ${kleur.blue(cwd)} with ${kleur.blue(\n 'gradle'\n )}`\n );\n\n const gradleWrapper = platform() === 'win32' ? 'gradlew.bat' : './gradlew';\n if (await fs.pathExists(path.join(androidPath, gradleWrapper))) {\n execFileSync(gradleWrapper, ['assemble'], { cwd: androidPath });\n } else {\n throw new Error(\n `The ${kleur.blue(\n 'gradlew'\n )} script doesn't seem to present in ${kleur.blue(\n androidPath\n )}. Make sure you have added it by running ${kleur.blue(\n 'gradle wrapper'\n )} in that directory.`\n );\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,GAAA,GAAAJ,OAAA;AAA8B,SAAAD,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AASf,eAAeG,eAAeA,CAAC;EAC5CC,IAAI;EACJC,WAAW;EACXC;AACO,CAAC,EAAE;EACV,MAAMC,GAAG,GAAGC,aAAI,CAACC,QAAQ,CAACL,IAAI,EAAEC,WAAW,CAAC;EAE5CC,MAAM,CAACI,IAAI,CACR,iCAAgCC,cAAK,CAACC,IAAI,CAACL,GAAG,CAAE,SAAQI,cAAK,CAACC,IAAI,CACjE,QACF,CAAE,EACJ,CAAC;EAED,MAAMC,aAAa,GAAG,IAAAC,YAAQ,EAAC,CAAC,KAAK,OAAO,GAAG,aAAa,GAAG,WAAW;EAC1E,IAAI,MAAMC,gBAAE,CAACC,UAAU,CAACR,aAAI,CAACS,IAAI,CAACZ,WAAW,EAAEQ,aAAa,CAAC,CAAC,EAAE;IAC9D,IAAAK,2BAAY,EAACL,aAAa,EAAE,CAAC,UAAU,CAAC,EAAE;MAAEN,GAAG,EAAEF;IAAY,CAAC,CAAC;EACjE,CAAC,MAAM;IACL,MAAM,IAAIc,KAAK,CACZ,OAAMR,cAAK,CAACC,IAAI,CACf,SACF,CAAE,sCAAqCD,cAAK,CAACC,IAAI,CAC/CP,WACF,CAAE,4CAA2CM,cAAK,CAACC,IAAI,CACrD,gBACF,CAAE,qBACJ,CAAC;EACH;AACF"}
|
package/lib/utils/compile.js
CHANGED
|
@@ -4,25 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = compile;
|
|
7
|
-
|
|
8
7
|
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
|
|
10
8
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
11
|
-
|
|
12
9
|
var _kleur = _interopRequireDefault(require("kleur"));
|
|
13
|
-
|
|
14
10
|
var babel = _interopRequireWildcard(require("@babel/core"));
|
|
15
|
-
|
|
16
11
|
var _browserslist = _interopRequireDefault(require("browserslist"));
|
|
17
|
-
|
|
18
12
|
var _glob = _interopRequireDefault(require("glob"));
|
|
19
|
-
|
|
20
13
|
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); }
|
|
21
|
-
|
|
22
14
|
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; }
|
|
23
|
-
|
|
24
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
16
|
async function compile({
|
|
27
17
|
root,
|
|
28
18
|
source,
|
|
@@ -42,28 +32,21 @@ async function compile({
|
|
|
42
32
|
nodir: true,
|
|
43
33
|
ignore: exclude
|
|
44
34
|
});
|
|
45
|
-
|
|
46
35
|
report.info(`Compiling ${_kleur.default.blue(String(files.length))} files in ${_kleur.default.blue(_path.default.relative(root, source))} with ${_kleur.default.blue('babel')}`);
|
|
47
36
|
const pkg = JSON.parse(await _fsExtra.default.readFile(_path.default.join(root, 'package.json'), 'utf-8'));
|
|
48
|
-
|
|
49
37
|
if (copyFlow) {
|
|
50
38
|
if (!Object.keys(pkg.devDependencies || {}).includes('flow-bin')) {
|
|
51
39
|
report.warn(`The ${_kleur.default.blue('copyFlow')} option was specified, but couldn't find ${_kleur.default.blue('flow-bin')} in ${_kleur.default.blue('package.json')}.\nIf the project is using ${_kleur.default.blue('flow')}, then make sure you have added ${_kleur.default.blue('flow-bin')} to your ${_kleur.default.blue('devDependencies')}, otherwise remove the ${_kleur.default.blue('copyFlow')} option.`);
|
|
52
40
|
}
|
|
53
41
|
}
|
|
54
|
-
|
|
55
42
|
await Promise.all(files.map(async filepath => {
|
|
56
43
|
const outputFilename = _path.default.join(output, _path.default.relative(source, filepath)).replace(/\.(jsx?|tsx?)$/, '.js');
|
|
57
|
-
|
|
58
44
|
await _fsExtra.default.mkdirp(_path.default.dirname(outputFilename));
|
|
59
|
-
|
|
60
45
|
if (!/\.(jsx?|tsx?)$/.test(filepath)) {
|
|
61
46
|
// Copy files which aren't source code
|
|
62
47
|
_fsExtra.default.copy(filepath, outputFilename);
|
|
63
|
-
|
|
64
48
|
return;
|
|
65
49
|
}
|
|
66
|
-
|
|
67
50
|
const content = await _fsExtra.default.readFile(filepath, 'utf-8');
|
|
68
51
|
const result = await babel.transformAsync(content, {
|
|
69
52
|
cwd: root,
|
|
@@ -84,59 +67,46 @@ async function compile({
|
|
|
84
67
|
}], require.resolve('@babel/preset-react'), require.resolve('@babel/preset-typescript'), require.resolve('@babel/preset-flow')]
|
|
85
68
|
})
|
|
86
69
|
});
|
|
87
|
-
|
|
88
70
|
if (result == null) {
|
|
89
71
|
throw new Error('Output code was null');
|
|
90
72
|
}
|
|
91
|
-
|
|
92
73
|
let code = result.code;
|
|
93
|
-
|
|
94
74
|
if (sourceMaps && result.map) {
|
|
95
75
|
const mapFilename = outputFilename + '.map';
|
|
96
|
-
code += '\n//# sourceMappingURL=' + _path.default.basename(mapFilename);
|
|
76
|
+
code += '\n//# sourceMappingURL=' + _path.default.basename(mapFilename);
|
|
97
77
|
|
|
78
|
+
// Don't inline the source code, it can be retrieved from the source file
|
|
98
79
|
result.map.sourcesContent = undefined;
|
|
99
|
-
|
|
100
|
-
_fsExtra.default.writeFileSync(mapFilename, JSON.stringify(result.map));
|
|
80
|
+
await _fsExtra.default.writeJSON(mapFilename, result.map);
|
|
101
81
|
}
|
|
102
|
-
|
|
103
82
|
await _fsExtra.default.writeFile(outputFilename, code);
|
|
104
|
-
|
|
105
83
|
if (copyFlow) {
|
|
106
84
|
_fsExtra.default.copy(filepath, outputFilename + '.flow');
|
|
107
85
|
}
|
|
108
86
|
}));
|
|
109
87
|
report.success(`Wrote files to ${_kleur.default.blue(_path.default.relative(root, output))}`);
|
|
110
|
-
|
|
111
88
|
const getGeneratedEntryPath = async () => {
|
|
112
89
|
if (pkg.source) {
|
|
113
90
|
const indexName = _path.default.basename(pkg.source).replace(/\.(jsx?|tsx?)$/, '') + '.js';
|
|
114
|
-
|
|
115
91
|
const potentialPath = _path.default.join(output, _path.default.dirname(_path.default.relative(source, _path.default.join(root, pkg.source))), indexName);
|
|
116
|
-
|
|
117
92
|
if (await _fsExtra.default.pathExists(potentialPath)) {
|
|
118
93
|
return _path.default.relative(root, potentialPath);
|
|
119
94
|
}
|
|
120
95
|
}
|
|
121
|
-
|
|
122
96
|
return null;
|
|
123
97
|
};
|
|
124
|
-
|
|
125
98
|
if (field in pkg) {
|
|
126
99
|
try {
|
|
127
100
|
require.resolve(_path.default.join(root, pkg[field]));
|
|
128
101
|
} catch (e) {
|
|
129
102
|
if (e != null && typeof e === 'object' && 'code' in e && e.code === 'MODULE_NOT_FOUND') {
|
|
130
103
|
const generatedEntryPath = await getGeneratedEntryPath();
|
|
131
|
-
|
|
132
104
|
if (!generatedEntryPath) {
|
|
133
105
|
report.warn(`Failed to detect the entry point for the generated files. Make sure you have a valid ${_kleur.default.blue('source')} field in your ${_kleur.default.blue('package.json')}.`);
|
|
134
106
|
}
|
|
135
|
-
|
|
136
107
|
report.error(`The ${_kleur.default.blue(field)} field in ${_kleur.default.blue('package.json')} points to a non-existent file: ${_kleur.default.blue(pkg[field])}.\nVerify the path points to the correct file under ${_kleur.default.blue(_path.default.relative(root, output))}${generatedEntryPath ? ` (found ${_kleur.default.blue(generatedEntryPath)}).` : '.'}`);
|
|
137
108
|
throw new Error(`Found incorrect path in '${field}' field.`);
|
|
138
109
|
}
|
|
139
|
-
|
|
140
110
|
throw e;
|
|
141
111
|
}
|
|
142
112
|
} else {
|
package/lib/utils/compile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.js","names":["compile","root","source","output","babelrc","configFile","exclude","modules","copyFlow","sourceMaps","report","field","files","glob","sync","cwd","absolute","nodir","ignore","info","kleur","blue","String","length","path","relative","pkg","JSON","parse","fs","readFile","join","Object","keys","devDependencies","includes","warn","Promise","all","map","filepath","outputFilename","replace","mkdirp","dirname","test","copy","content","result","babel","transformAsync","sourceRoot","sourceFileName","filename","presets","require","resolve","targets","browserslist","findConfig","browsers","node","useBuiltIns","Error","code","mapFilename","basename","sourcesContent","undefined","writeFileSync","stringify","writeFile","success","getGeneratedEntryPath","indexName","potentialPath","pathExists","e","generatedEntryPath","error"],"sources":["../../src/utils/compile.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs-extra';\nimport kleur from 'kleur';\nimport * as babel from '@babel/core';\nimport browserslist from 'browserslist';\nimport glob from 'glob';\nimport type { Input } from '../types';\n\ntype Options = Input & {\n babelrc?: boolean | null;\n configFile?: string | false | null;\n sourceMaps?: boolean;\n copyFlow?: boolean;\n modules: 'commonjs' | false;\n field: 'main' | 'module';\n exclude: string;\n};\n\nexport default async function compile({\n root,\n source,\n output,\n babelrc = false,\n configFile = false,\n exclude,\n modules,\n copyFlow,\n sourceMaps = true,\n report,\n field,\n}: Options) {\n const files = glob.sync('**/*', {\n cwd: source,\n absolute: true,\n nodir: true,\n ignore: exclude,\n });\n\n report.info(\n `Compiling ${kleur.blue(String(files.length))} files in ${kleur.blue(\n path.relative(root, source)\n )} with ${kleur.blue('babel')}`\n );\n\n const pkg = JSON.parse(\n await fs.readFile(path.join(root, 'package.json'), 'utf-8')\n );\n\n if (copyFlow) {\n if (!Object.keys(pkg.devDependencies || {}).includes('flow-bin')) {\n report.warn(\n `The ${kleur.blue(\n 'copyFlow'\n )} option was specified, but couldn't find ${kleur.blue(\n 'flow-bin'\n )} in ${kleur.blue(\n 'package.json'\n )}.\\nIf the project is using ${kleur.blue(\n 'flow'\n )}, then make sure you have added ${kleur.blue(\n 'flow-bin'\n )} to your ${kleur.blue(\n 'devDependencies'\n )}, otherwise remove the ${kleur.blue('copyFlow')} option.`\n );\n }\n }\n\n await Promise.all(\n files.map(async (filepath) => {\n const outputFilename = path\n .join(output, path.relative(source, filepath))\n .replace(/\\.(jsx?|tsx?)$/, '.js');\n\n await fs.mkdirp(path.dirname(outputFilename));\n\n if (!/\\.(jsx?|tsx?)$/.test(filepath)) {\n // Copy files which aren't source code\n fs.copy(filepath, outputFilename);\n return;\n }\n\n const content = await fs.readFile(filepath, 'utf-8');\n const result = await babel.transformAsync(content, {\n cwd: root,\n babelrc: babelrc,\n configFile: configFile,\n sourceMaps,\n sourceRoot: path.relative(path.dirname(outputFilename), source),\n sourceFileName: path.relative(source, filepath),\n filename: filepath,\n ...(babelrc || configFile\n ? null\n : {\n presets: [\n [\n require.resolve('@babel/preset-env'),\n {\n targets: browserslist.findConfig(root) ?? {\n browsers: [\n '>1%',\n 'last 2 chrome versions',\n 'last 2 edge versions',\n 'last 2 firefox versions',\n 'last 2 safari versions',\n 'not dead',\n 'not ie <= 11',\n 'not op_mini all',\n 'not android <= 4.4',\n 'not samsung <= 4',\n ],\n node: '18',\n },\n useBuiltIns: false,\n modules,\n },\n ],\n require.resolve('@babel/preset-react'),\n require.resolve('@babel/preset-typescript'),\n require.resolve('@babel/preset-flow'),\n ],\n }),\n });\n\n if (result == null) {\n throw new Error('Output code was null');\n }\n\n let code = result.code;\n\n if (sourceMaps && result.map) {\n const mapFilename = outputFilename + '.map';\n\n code += '\\n//# sourceMappingURL=' + path.basename(mapFilename);\n\n // Don't inline the source code, it can be retrieved from the source file\n result.map.sourcesContent = undefined;\n\n fs.writeFileSync(mapFilename, JSON.stringify(result.map));\n }\n\n await fs.writeFile(outputFilename, code);\n\n if (copyFlow) {\n fs.copy(filepath, outputFilename + '.flow');\n }\n })\n );\n\n report.success(`Wrote files to ${kleur.blue(path.relative(root, output))}`);\n\n const getGeneratedEntryPath = async () => {\n if (pkg.source) {\n const indexName =\n path.basename(pkg.source).replace(/\\.(jsx?|tsx?)$/, '') + '.js';\n\n const potentialPath = path.join(\n output,\n path.dirname(path.relative(source, path.join(root, pkg.source))),\n indexName\n );\n\n if (await fs.pathExists(potentialPath)) {\n return path.relative(root, potentialPath);\n }\n }\n\n return null;\n };\n\n if (field in pkg) {\n try {\n require.resolve(path.join(root, pkg[field]));\n } catch (e: unknown) {\n if (\n e != null &&\n typeof e === 'object' &&\n 'code' in e &&\n e.code === 'MODULE_NOT_FOUND'\n ) {\n const generatedEntryPath = await getGeneratedEntryPath();\n\n if (!generatedEntryPath) {\n report.warn(\n `Failed to detect the entry point for the generated files. Make sure you have a valid ${kleur.blue(\n 'source'\n )} field in your ${kleur.blue('package.json')}.`\n );\n }\n\n report.error(\n `The ${kleur.blue(field)} field in ${kleur.blue(\n 'package.json'\n )} points to a non-existent file: ${kleur.blue(\n pkg[field]\n )}.\\nVerify the path points to the correct file under ${kleur.blue(\n path.relative(root, output)\n )}${\n generatedEntryPath\n ? ` (found ${kleur.blue(generatedEntryPath)}).`\n : '.'\n }`\n );\n\n throw new Error(`Found incorrect path in '${field}' field.`);\n }\n\n throw e;\n }\n } else {\n const generatedEntryPath = await getGeneratedEntryPath();\n\n report.warn(\n `No ${kleur.blue(field)} field found in ${kleur.blue(\n 'package.json'\n )}. Consider ${\n generatedEntryPath\n ? `pointing it to ${kleur.blue(generatedEntryPath)}`\n : 'adding it'\n } so that consumers of your package can use it.`\n );\n }\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAae,eAAeA,OAAf,CAAuB;EACpCC,IADoC;EAEpCC,MAFoC;EAGpCC,MAHoC;EAIpCC,OAAO,GAAG,KAJ0B;EAKpCC,UAAU,GAAG,KALuB;EAMpCC,OANoC;EAOpCC,OAPoC;EAQpCC,QARoC;EASpCC,UAAU,GAAG,IATuB;EAUpCC,MAVoC;EAWpCC;AAXoC,CAAvB,EAYH;EACV,MAAMC,KAAK,GAAGC,aAAA,CAAKC,IAAL,CAAU,MAAV,EAAkB;IAC9BC,GAAG,EAAEb,MADyB;IAE9Bc,QAAQ,EAAE,IAFoB;IAG9BC,KAAK,EAAE,IAHuB;IAI9BC,MAAM,EAAEZ;EAJsB,CAAlB,CAAd;;EAOAI,MAAM,CAACS,IAAP,CACG,aAAYC,cAAA,CAAMC,IAAN,CAAWC,MAAM,CAACV,KAAK,CAACW,MAAP,CAAjB,CAAiC,aAAYH,cAAA,CAAMC,IAAN,CACxDG,aAAA,CAAKC,QAAL,CAAcxB,IAAd,EAAoBC,MAApB,CADwD,CAExD,SAAQkB,cAAA,CA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C0B,IAAP,CACG,MAAKhB,cAAA,CAAMC,IAAN,CAAWV,KAAX,CAAkB,mBAAkBS,cAAA,CAAMC,IAAN,CACxC,cADwC,CAExC,cACAyD,kBAAkB,GACb,kBAAiB1D,cAAA,CAAMC,IAAN,CAAWyD,kBAAX,CAA+B,EADnC,GAEd,WACL,gDAPH;EASD;AACF"}
|
|
1
|
+
{"version":3,"file":"compile.js","names":["_path","_interopRequireDefault","require","_fsExtra","_kleur","babel","_interopRequireWildcard","_browserslist","_glob","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","compile","root","source","output","babelrc","configFile","exclude","modules","copyFlow","sourceMaps","report","field","files","glob","sync","cwd","absolute","nodir","ignore","info","kleur","blue","String","length","path","relative","pkg","JSON","parse","fs","readFile","join","keys","devDependencies","includes","warn","Promise","all","map","filepath","outputFilename","replace","mkdirp","dirname","test","copy","content","result","transformAsync","sourceRoot","sourceFileName","filename","presets","resolve","targets","browserslist","findConfig","browsers","node","useBuiltIns","Error","code","mapFilename","basename","sourcesContent","undefined","writeJSON","writeFile","success","getGeneratedEntryPath","indexName","potentialPath","pathExists","e","generatedEntryPath","error"],"sources":["../../src/utils/compile.ts"],"sourcesContent":["import path from 'path';\nimport fs from 'fs-extra';\nimport kleur from 'kleur';\nimport * as babel from '@babel/core';\nimport browserslist from 'browserslist';\nimport glob from 'glob';\nimport type { Input } from '../types';\n\ntype Options = Input & {\n babelrc?: boolean | null;\n configFile?: string | false | null;\n sourceMaps?: boolean;\n copyFlow?: boolean;\n modules: 'commonjs' | false;\n field: 'main' | 'module';\n exclude: string;\n};\n\nexport default async function compile({\n root,\n source,\n output,\n babelrc = false,\n configFile = false,\n exclude,\n modules,\n copyFlow,\n sourceMaps = true,\n report,\n field,\n}: Options) {\n const files = glob.sync('**/*', {\n cwd: source,\n absolute: true,\n nodir: true,\n ignore: exclude,\n });\n\n report.info(\n `Compiling ${kleur.blue(String(files.length))} files in ${kleur.blue(\n path.relative(root, source)\n )} with ${kleur.blue('babel')}`\n );\n\n const pkg = JSON.parse(\n await fs.readFile(path.join(root, 'package.json'), 'utf-8')\n );\n\n if (copyFlow) {\n if (!Object.keys(pkg.devDependencies || {}).includes('flow-bin')) {\n report.warn(\n `The ${kleur.blue(\n 'copyFlow'\n )} option was specified, but couldn't find ${kleur.blue(\n 'flow-bin'\n )} in ${kleur.blue(\n 'package.json'\n )}.\\nIf the project is using ${kleur.blue(\n 'flow'\n )}, then make sure you have added ${kleur.blue(\n 'flow-bin'\n )} to your ${kleur.blue(\n 'devDependencies'\n )}, otherwise remove the ${kleur.blue('copyFlow')} option.`\n );\n }\n }\n\n await Promise.all(\n files.map(async (filepath) => {\n const outputFilename = path\n .join(output, path.relative(source, filepath))\n .replace(/\\.(jsx?|tsx?)$/, '.js');\n\n await fs.mkdirp(path.dirname(outputFilename));\n\n if (!/\\.(jsx?|tsx?)$/.test(filepath)) {\n // Copy files which aren't source code\n fs.copy(filepath, outputFilename);\n return;\n }\n\n const content = await fs.readFile(filepath, 'utf-8');\n const result = await babel.transformAsync(content, {\n cwd: root,\n babelrc: babelrc,\n configFile: configFile,\n sourceMaps,\n sourceRoot: path.relative(path.dirname(outputFilename), source),\n sourceFileName: path.relative(source, filepath),\n filename: filepath,\n ...(babelrc || configFile\n ? null\n : {\n presets: [\n [\n require.resolve('@babel/preset-env'),\n {\n targets: browserslist.findConfig(root) ?? {\n browsers: [\n '>1%',\n 'last 2 chrome versions',\n 'last 2 edge versions',\n 'last 2 firefox versions',\n 'last 2 safari versions',\n 'not dead',\n 'not ie <= 11',\n 'not op_mini all',\n 'not android <= 4.4',\n 'not samsung <= 4',\n ],\n node: '18',\n },\n useBuiltIns: false,\n modules,\n },\n ],\n require.resolve('@babel/preset-react'),\n require.resolve('@babel/preset-typescript'),\n require.resolve('@babel/preset-flow'),\n ],\n }),\n });\n\n if (result == null) {\n throw new Error('Output code was null');\n }\n\n let code = result.code;\n\n if (sourceMaps && result.map) {\n const mapFilename = outputFilename + '.map';\n\n code += '\\n//# sourceMappingURL=' + path.basename(mapFilename);\n\n // Don't inline the source code, it can be retrieved from the source file\n result.map.sourcesContent = undefined;\n\n await fs.writeJSON(mapFilename, result.map);\n }\n\n await fs.writeFile(outputFilename, code);\n\n if (copyFlow) {\n fs.copy(filepath, outputFilename + '.flow');\n }\n })\n );\n\n report.success(`Wrote files to ${kleur.blue(path.relative(root, output))}`);\n\n const getGeneratedEntryPath = async () => {\n if (pkg.source) {\n const indexName =\n path.basename(pkg.source).replace(/\\.(jsx?|tsx?)$/, '') + '.js';\n\n const potentialPath = path.join(\n output,\n path.dirname(path.relative(source, path.join(root, pkg.source))),\n indexName\n );\n\n if (await fs.pathExists(potentialPath)) {\n return path.relative(root, potentialPath);\n }\n }\n\n return null;\n };\n\n if (field in pkg) {\n try {\n require.resolve(path.join(root, pkg[field]));\n } catch (e: unknown) {\n if (\n e != null &&\n typeof e === 'object' &&\n 'code' in e &&\n e.code === 'MODULE_NOT_FOUND'\n ) {\n const generatedEntryPath = await getGeneratedEntryPath();\n\n if (!generatedEntryPath) {\n report.warn(\n `Failed to detect the entry point for the generated files. Make sure you have a valid ${kleur.blue(\n 'source'\n )} field in your ${kleur.blue('package.json')}.`\n );\n }\n\n report.error(\n `The ${kleur.blue(field)} field in ${kleur.blue(\n 'package.json'\n )} points to a non-existent file: ${kleur.blue(\n pkg[field]\n )}.\\nVerify the path points to the correct file under ${kleur.blue(\n path.relative(root, output)\n )}${\n generatedEntryPath\n ? ` (found ${kleur.blue(generatedEntryPath)}).`\n : '.'\n }`\n );\n\n throw new Error(`Found incorrect path in '${field}' field.`);\n }\n\n throw e;\n }\n } else {\n const generatedEntryPath = await getGeneratedEntryPath();\n\n report.warn(\n `No ${kleur.blue(field)} field found in ${kleur.blue(\n 'package.json'\n )}. Consider ${\n generatedEntryPath\n ? `point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,CAACZ,IAAI,KAAK,kBAAkB,EAC7B;QACA,MAAMa,kBAAkB,GAAG,MAAML,qBAAqB,CAAC,CAAC;QAExD,IAAI,CAACK,kBAAkB,EAAE;UACvBhE,MAAM,CAACyB,IAAI,CACR,wFAAuFf,cAAK,CAACC,IAAI,CAChG,QACF,CAAE,kBAAiBD,cAAK,CAACC,IAAI,CAAC,cAAc,CAAE,GAChD,CAAC;QACH;QAEAX,MAAM,CAACiE,KAAK,CACT,OAAMvD,cAAK,CAACC,IAAI,CAACV,KAAK,CAAE,aAAYS,cAAK,CAACC,IAAI,CAC7C,cACF,CAAE,mCAAkCD,cAAK,CAACC,IAAI,CAC5CK,GAAG,CAACf,KAAK,CACX,CAAE,uDAAsDS,cAAK,CAACC,IAAI,CAChEG,aAAI,CAACC,QAAQ,CAACxB,IAAI,EAAEE,MAAM,CAC5B,CAAE,GACAuE,kBAAkB,GACb,WAAUtD,cAAK,CAACC,IAAI,CAACqD,kBAAkB,CAAE,IAAG,GAC7C,GACL,EACH,CAAC;QAED,MAAM,IAAId,KAAK,CAAE,4BAA2BjD,KAAM,UAAS,CAAC;MAC9D;MAEA,MAAM8D,CAAC;IACT;EACF,CAAC,MAAM;IACL,MAAMC,kBAAkB,GAAG,MAAML,qBAAqB,CAAC,CAAC;IAExD3D,MAAM,CAACyB,IAAI,CACR,MAAKf,cAAK,CAACC,IAAI,CAACV,KAAK,CAAE,mBAAkBS,cAAK,CAACC,IAAI,CAClD,cACF,CAAE,cACAqD,kBAAkB,GACb,kBAAiBtD,cAAK,CAACC,IAAI,CAACqD,kBAAkB,CAAE,EAAC,GAClD,WACL,gDACH,CAAC;EACH;AACF"}
|
package/lib/utils/logger.js
CHANGED
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.warn = exports.success = exports.info = exports.exit = exports.error = void 0;
|
|
7
|
-
|
|
8
7
|
var _kleur = _interopRequireDefault(require("kleur"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
const logger = (type, color) => (...messages) => {
|
|
13
10
|
console.log(color(_kleur.default.bold(type)), ...messages.map(message => {
|
|
14
11
|
if (typeof message === 'string') {
|
|
@@ -18,7 +15,6 @@ const logger = (type, color) => (...messages) => {
|
|
|
18
15
|
}
|
|
19
16
|
}));
|
|
20
17
|
};
|
|
21
|
-
|
|
22
18
|
const info = logger('ℹ', _kleur.default.blue);
|
|
23
19
|
exports.info = info;
|
|
24
20
|
const warn = logger('⚠', _kleur.default.yellow);
|
|
@@ -27,11 +23,9 @@ const error = logger('✖', _kleur.default.red);
|
|
|
27
23
|
exports.error = error;
|
|
28
24
|
const success = logger('✔', _kleur.default.green);
|
|
29
25
|
exports.success = success;
|
|
30
|
-
|
|
31
26
|
const exit = (...messages) => {
|
|
32
27
|
error(...messages);
|
|
33
28
|
process.exit(1);
|
|
34
29
|
};
|
|
35
|
-
|
|
36
30
|
exports.exit = exit;
|
|
37
31
|
//# sourceMappingURL=logger.js.map
|
package/lib/utils/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","names":["logger","type","color","messages","console","log","kleur","bold","map","message","split","join","info","blue","warn","yellow","error","red","success","green","exit","process"],"sources":["../../src/utils/logger.ts"],"sourcesContent":["import kleur from 'kleur';\n\nconst logger =\n (type: string, color: Function) =>\n (...messages: unknown[]) => {\n console.log(\n color(kleur.bold(type)),\n ...messages.map((message) => {\n if (typeof message === 'string') {\n return message.split('\\n').join(`\\n `);\n } else {\n return message;\n }\n })\n );\n };\n\nexport const info = logger('ℹ', kleur.blue);\nexport const warn = logger('⚠', kleur.yellow);\nexport const error = logger('✖', kleur.red);\nexport const success = logger('✔', kleur.green);\n\nexport const exit = (...messages: unknown[]) => {\n error(...messages);\n process.exit(1);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.js","names":["_kleur","_interopRequireDefault","require","obj","__esModule","default","logger","type","color","messages","console","log","kleur","bold","map","message","split","join","info","blue","exports","warn","yellow","error","red","success","green","exit","process"],"sources":["../../src/utils/logger.ts"],"sourcesContent":["import kleur from 'kleur';\n\nconst logger =\n (type: string, color: Function) =>\n (...messages: unknown[]) => {\n console.log(\n color(kleur.bold(type)),\n ...messages.map((message) => {\n if (typeof message === 'string') {\n return message.split('\\n').join(`\\n `);\n } else {\n return message;\n }\n })\n );\n };\n\nexport const info = logger('ℹ', kleur.blue);\nexport const warn = logger('⚠', kleur.yellow);\nexport const error = logger('✖', kleur.red);\nexport const success = logger('✔', kleur.green);\n\nexport const exit = (...messages: unknown[]) => {\n error(...messages);\n process.exit(1);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE1B,MAAMG,MAAM,GACVA,CAACC,IAAY,EAAEC,KAAe,KAC9B,CAAC,GAAGC,QAAmB,KAAK;EAC1BC,OAAO,CAACC,GAAG,CACTH,KAAK,CAACI,cAAK,CAACC,IAAI,CAACN,IAAI,CAAC,CAAC,EACvB,GAAGE,QAAQ,CAACK,GAAG,CAAEC,OAAO,IAAK;IAC3B,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;MAC/B,OAAOA,OAAO,CAACC,KAAK,CAAC,IAAI,CAAC,CAACC,IAAI,CAAE,MAAK,CAAC;IACzC,CAAC,MAAM;MACL,OAAOF,OAAO;IAChB;EACF,CAAC,CACH,CAAC;AACH,CAAC;AAEI,MAAMG,IAAI,GAAGZ,MAAM,CAAC,GAAG,EAAEM,cAAK,CAACO,IAAI,CAAC;AAACC,OAAA,CAAAF,IAAA,GAAAA,IAAA;AACrC,MAAMG,IAAI,GAAGf,MAAM,CAAC,GAAG,EAAEM,cAAK,CAACU,MAAM,CAAC;AAACF,OAAA,CAAAC,IAAA,GAAAA,IAAA;AACvC,MAAME,KAAK,GAAGjB,MAAM,CAAC,GAAG,EAAEM,cAAK,CAACY,GAAG,CAAC;AAACJ,OAAA,CAAAG,KAAA,GAAAA,KAAA;AACrC,MAAME,OAAO,GAAGnB,MAAM,CAAC,GAAG,EAAEM,cAAK,CAACc,KAAK,CAAC;AAACN,OAAA,CAAAK,OAAA,GAAAA,OAAA;AAEzC,MAAME,IAAI,GAAGA,CAAC,GAAGlB,QAAmB,KAAK;EAC9Cc,KAAK,CAAC,GAAGd,QAAQ,CAAC;EAClBmB,OAAO,CAACD,IAAI,CAAC,CAAC,CAAC;AACjB,CAAC;AAACP,OAAA,CAAAO,IAAA,GAAAA,IAAA"}
|
package/lib/utils/prompts.js
CHANGED
|
@@ -4,17 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = prompts;
|
|
7
|
-
|
|
8
7
|
var _prompts = _interopRequireDefault(require("prompts"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
function prompts(args, options) {
|
|
13
10
|
return (0, _prompts.default)(args, {
|
|
14
11
|
onCancel() {
|
|
15
12
|
process.exit(1);
|
|
16
13
|
},
|
|
17
|
-
|
|
18
14
|
...options
|
|
19
15
|
});
|
|
20
16
|
}
|
package/lib/utils/prompts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","names":["prompts","args","options","promptsModule","onCancel","process","exit"],"sources":["../../src/utils/prompts.ts"],"sourcesContent":["import promptsModule from 'prompts';\n\nexport default function prompts(\n args: promptsModule.PromptObject | promptsModule.PromptObject[],\n options?: promptsModule.Options\n) {\n return promptsModule(args, {\n onCancel() {\n process.exit(1);\n },\n ...options,\n });\n}\n\nexport type PromptObject<T extends string = string> =\n promptsModule.PromptObject<T>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"prompts.js","names":["_prompts","_interopRequireDefault","require","obj","__esModule","default","prompts","args","options","promptsModule","onCancel","process","exit"],"sources":["../../src/utils/prompts.ts"],"sourcesContent":["import promptsModule from 'prompts';\n\nexport default function prompts(\n args: promptsModule.PromptObject | promptsModule.PromptObject[],\n options?: promptsModule.Options\n) {\n return promptsModule(args, {\n onCancel() {\n process.exit(1);\n },\n ...options,\n });\n}\n\nexport type PromptObject<T extends string = string> =\n promptsModule.PromptObject<T>;\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAErB,SAASG,OAAOA,CAC7BC,IAA+D,EAC/DC,OAA+B,EAC/B;EACA,OAAO,IAAAC,gBAAa,EAACF,IAAI,EAAE;IACzBG,QAAQA,CAAA,EAAG;MACTC,OAAO,CAACC,IAAI,CAAC,CAAC,CAAC;IACjB,CAAC;IACD,GAAGJ;EACL,CAAC,CAAC;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-builder-bob",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "CLI to build JavaScript files for React Native libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"registry": "https://registry.npmjs.org/"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
|
-
"
|
|
36
|
+
"prepare": "babel --extensions .ts,.tsx src --out-dir lib --source-maps --delete-dir-on-start"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@babel/core": "^7.18.5",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"@types/yargs": "^17.0.10",
|
|
72
72
|
"concurrently": "^7.2.2"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "51fc83e7e3f4e5482b81f7f9e3dff748e474cd16"
|
|
75
75
|
}
|