1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | var __importStar = (this && this.__importStar) || function (mod) {
|
7 | if (mod && mod.__esModule) return mod;
|
8 | var result = {};
|
9 | if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
10 | result["default"] = mod;
|
11 | return result;
|
12 | };
|
13 | Object.defineProperty(exports, "__esModule", { value: true });
|
14 | const fs = __importStar(require("fs-extra"));
|
15 | const path = __importStar(require("path"));
|
16 | const utils = __importStar(require("./utils"));
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | if (process.argv.length < 3) {
|
29 | const msg = '** Must supply a target extension';
|
30 | process.stderr.write(msg);
|
31 | process.exit(1);
|
32 | }
|
33 |
|
34 | const target = process.argv[2];
|
35 | const basePath = path.resolve('.');
|
36 | let packageDirName = path.basename(target);
|
37 | let packagePath = path.resolve(target);
|
38 | if (fs.existsSync(packagePath)) {
|
39 |
|
40 | const newPackagePath = path.join(basePath, 'packages', packageDirName);
|
41 | fs.copySync(packagePath, newPackagePath);
|
42 | packagePath = newPackagePath;
|
43 | }
|
44 | else {
|
45 |
|
46 | packageDirName = target
|
47 | .split('/')
|
48 | .pop()
|
49 | .split('.')[0];
|
50 | packagePath = path.join(basePath, 'packages', packageDirName);
|
51 | utils.run('git clone ' + target + ' ' + packagePath);
|
52 | }
|
53 |
|
54 | if (fs.existsSync(path.join(packagePath, 'node_modules'))) {
|
55 | fs.removeSync(path.join(packagePath, 'node_modules'));
|
56 | }
|
57 |
|
58 | const packageTsconfigPath = path.join(packagePath, 'tsconfig.json');
|
59 | if (fs.existsSync(packageTsconfigPath)) {
|
60 | const packageTsconfig = utils.readJSONFile(packageTsconfigPath);
|
61 | packageTsconfig.compilerOptions.composite = true;
|
62 | utils.writeJSONFile(packageTsconfigPath, packageTsconfig);
|
63 | }
|
64 |
|
65 | const pkgJSONPath = path.join(packagePath, 'package.json');
|
66 | const data = utils.readJSONFile(pkgJSONPath);
|
67 | if (data.private !== true) {
|
68 | data.publishConfig = {};
|
69 | data.publishConfig.access = 'public';
|
70 | utils.writeJSONFile(pkgJSONPath, data);
|
71 | }
|
72 |
|
73 | const tsconfigPath = path.join(basePath, 'packages', 'metapackage', 'tsconfig.json');
|
74 | const tsconfig = utils.readJSONFile(tsconfigPath);
|
75 | tsconfig.references.push({
|
76 | path: path.join('..', '..', packageDirName)
|
77 | });
|
78 | utils.writeJSONFile(tsconfigPath, tsconfig);
|
79 |
|
80 | utils.run('jlpm run integrity');
|
81 |
|
\ | No newline at end of file |