@goldstack/utils-typescript-references 0.1.13 → 0.2.2
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/README.md +69 -16
- package/bin/utils-typescript-references +9 -1
- package/dist/src/updatePackageProjectReferences.d.ts +4 -1
- package/dist/src/updatePackageProjectReferences.d.ts.map +1 -1
- package/dist/src/updatePackageProjectReferences.js +11 -5
- package/dist/src/updatePackageProjectReferences.js.map +1 -1
- package/dist/src/updateRootProjectReferences.d.ts +4 -1
- package/dist/src/updateRootProjectReferences.d.ts.map +1 -1
- package/dist/src/updateRootProjectReferences.js +3 -3
- package/dist/src/updateRootProjectReferences.js.map +1 -1
- package/dist/src/utilsTypeScriptReferences.d.ts +1 -1
- package/dist/src/utilsTypeScriptReferences.d.ts.map +1 -1
- package/dist/src/utilsTypeScriptReferences.js +56 -25
- package/dist/src/utilsTypeScriptReferences.js.map +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -59,31 +59,83 @@ yarn fix-typescript-references
|
|
|
59
59
|
|
|
60
60
|
The following parameters can be passed when invoking the script:
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
### --help
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
Shows a reference of all available options:
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
```
|
|
67
|
+
$ utils-typescript-references --help
|
|
68
|
+
Options:
|
|
69
|
+
--help Show help [boolean]
|
|
70
|
+
--version Show version number [boolean]
|
|
71
|
+
--skipPackages Only update project references in the root tsConfig
|
|
72
|
+
[boolean]
|
|
73
|
+
--skipRoot Skip updating project references in project root
|
|
74
|
+
tsConfig [boolean]
|
|
75
|
+
--excludeInReferences Exclude specific packages from being referenced by
|
|
76
|
+
other packages [array]
|
|
77
|
+
--excludeInRoot Exclude specific packages from being referenced in the
|
|
78
|
+
root tsConfig [array]
|
|
79
|
+
--tsConfigName Names of tsConfig files to be updated [array]
|
|
80
|
+
```
|
|
67
81
|
|
|
68
|
-
|
|
82
|
+
### --tsConfigName
|
|
83
|
+
|
|
84
|
+
Provide one or more name of `tsconfig.json` files in projects across the monorepo that should be updated.
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
$ utils-typescript-references --tsConfigName tsconfig.json --tsConfigName tsconfig.build.json
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Defaults to `tsconfig.json`
|
|
69
91
|
|
|
70
|
-
`
|
|
92
|
+
This helpful for monorepos where for instance the `tsconfig.build.json` builds the modules that are exported from the package, and thus should be run when you are building using `tsc -b`. In this case the `tsconfig.json` can be set up to type check only (no emit) and have a manually inserted reference to `tsconfig.build.json` for running `tsc -b`.
|
|
71
93
|
|
|
72
|
-
|
|
73
|
-
with only `tsconfig.json` and not `tsconfig.build.json` will not have references inserted. This is intended
|
|
74
|
-
for monorepos where the `tsconfig.build.json` builds the modules that are exported from the package, and thus
|
|
75
|
-
should be run when you are building using `tsc -b`. In this case the `tsconfig.json` can be set up to type
|
|
76
|
-
check only (no emit) and have a manually inserted reference to `tsconfig.build.json` for running `tsc -b`.
|
|
94
|
+
Note that once any `--tsConfigName` is provided, the default `tsconfig.json` is not updated any more. In order to continue updating `tsconfig.json` along with any custom configuration files, simply provide it as an extra option:
|
|
77
95
|
|
|
78
|
-
|
|
96
|
+
```
|
|
97
|
+
$ utils-typescript-references --tsConfigName tsconfig.build.json --tsConfigName tsconfig.json
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
This option can also be used if the `tsconfig.json` file is not in the root of packages (e.g. in the `src/` folder). In that case, provide an option as follows:
|
|
79
101
|
|
|
80
|
-
|
|
81
|
-
|
|
102
|
+
```
|
|
103
|
+
$ utils-typescript-references --tsConfigName src/tsconfig.json --tsConfigName tsconfig.json
|
|
104
|
+
```
|
|
82
105
|
|
|
83
|
-
|
|
106
|
+
### --excludeInReferences
|
|
107
|
+
|
|
108
|
+
Will prevent certain packages from being added to the `references` of other projects in the monorepo.
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
$ utils-typescript-references --excludeInReferences @myproject/packageA --excludeInReferences @myproject/PackageB
|
|
112
|
+
```
|
|
84
113
|
|
|
85
|
-
|
|
86
|
-
|
|
114
|
+
The above will cause `@myproject/packageA` and `@myproject/packageB` not to be inserted as referenced in all other packages of the monorepo.
|
|
115
|
+
|
|
116
|
+
### --excludeInRoot
|
|
117
|
+
|
|
118
|
+
Will prevent certain packages from being added to the `references` section of the root `tsconfig.json` file.
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
$ utils-typescript-references --excludeInRoot @myproject/packageA --excludeInRoot @myproject/PackageB
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### --skipPackages
|
|
125
|
+
|
|
126
|
+
Will skip updating the `references` in `tsconfig.json` files for all packages in the project.
|
|
127
|
+
|
|
128
|
+
```
|
|
129
|
+
$ utils-typescript-references --skipPackages
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### -skipRoot
|
|
133
|
+
|
|
134
|
+
Will skip updating the `references` in the `tsconfig.json` file for the project root.
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
$ utils-typescript-references --skipRoot
|
|
138
|
+
```
|
|
87
139
|
|
|
88
140
|
## Limitations
|
|
89
141
|
|
|
@@ -93,6 +145,7 @@ If these limitations or anything else are an issues, please [raise a ticket in G
|
|
|
93
145
|
|
|
94
146
|
## See Also
|
|
95
147
|
|
|
148
|
+
- [Code with Joy - The Ultimate Guide to TypeScript Monorepos](https://maxrohde.com/2021/11/20/the-ultimate-guide-to-typescript-monorepos/)
|
|
96
149
|
- [The Full Stack Blog - TypeScript Monorepo with Yarn and Project References](https://maxrohde.com/2021/10/01/typescript-monorepo-with-yarn-and-project-references/)
|
|
97
150
|
- [@monorepo-utils/workspaces-to-typescript-project-references](https://github.com/azu/monorepo-utils/tree/master/packages/@monorepo-utils/workspaces-to-typescript-project-references#readme)
|
|
98
151
|
- [Optimizing multi-package apps with TypeScript Project References](https://ebaytech.berlin/optimizing-multi-package-apps-with-typescript-project-references-d5c57a3b4440)
|
|
@@ -3,4 +3,12 @@
|
|
|
3
3
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
4
4
|
require('source-map-support').install();
|
|
5
5
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
6
|
-
require('../dist/src/utilsTypeScriptReferences.js')
|
|
6
|
+
require('../dist/src/utilsTypeScriptReferences.js')
|
|
7
|
+
.run(process.argv)
|
|
8
|
+
.catch((e) => {
|
|
9
|
+
console.error(e);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
})
|
|
12
|
+
.then(() => {
|
|
13
|
+
// all good
|
|
14
|
+
});
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export declare const updatePackageProjectReferences: (tsConfigNames
|
|
1
|
+
export declare const updatePackageProjectReferences: ({ tsConfigNames, excludeInReferences, }: {
|
|
2
|
+
tsConfigNames: string[];
|
|
3
|
+
excludeInReferences: string[];
|
|
4
|
+
}) => void;
|
|
2
5
|
//# sourceMappingURL=updatePackageProjectReferences.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updatePackageProjectReferences.d.ts","sourceRoot":"","sources":["../../src/updatePackageProjectReferences.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,8BAA8B,
|
|
1
|
+
{"version":3,"file":"updatePackageProjectReferences.d.ts","sourceRoot":"","sources":["../../src/updatePackageProjectReferences.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,8BAA8B;mBAI1B,MAAM,EAAE;yBACF,MAAM,EAAE;MAC3B,IAwBH,CAAC"}
|
|
@@ -8,7 +8,7 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
8
8
|
const child_process_1 = require("child_process");
|
|
9
9
|
const sharedUtils_1 = require("./sharedUtils");
|
|
10
10
|
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const updatePackageProjectReferences = (tsConfigNames) => {
|
|
11
|
+
const updatePackageProjectReferences = ({ tsConfigNames, excludeInReferences, }) => {
|
|
12
12
|
const cmdRes = (0, child_process_1.execSync)('yarn workspaces list --json').toString();
|
|
13
13
|
const allPackages = (0, sharedUtils_1.getPackages)(cmdRes);
|
|
14
14
|
let isSuccess = true;
|
|
@@ -16,8 +16,12 @@ const updatePackageProjectReferences = (tsConfigNames) => {
|
|
|
16
16
|
const packageDir = packageData.path;
|
|
17
17
|
if (fs_1.default.existsSync(path_1.default.resolve(packageDir, './tsconfig.json'))) {
|
|
18
18
|
isSuccess =
|
|
19
|
-
processPackage(
|
|
20
|
-
|
|
19
|
+
processPackage({
|
|
20
|
+
packageDir,
|
|
21
|
+
allPackages,
|
|
22
|
+
tsConfigNames,
|
|
23
|
+
excludeInReferences,
|
|
24
|
+
}) === 'success' && isSuccess;
|
|
21
25
|
}
|
|
22
26
|
else {
|
|
23
27
|
console.log(`Skipping package ${packageDir}`);
|
|
@@ -28,7 +32,7 @@ const updatePackageProjectReferences = (tsConfigNames) => {
|
|
|
28
32
|
}
|
|
29
33
|
};
|
|
30
34
|
exports.updatePackageProjectReferences = updatePackageProjectReferences;
|
|
31
|
-
function processPackage(packageDir, allPackages,
|
|
35
|
+
function processPackage({ packageDir, allPackages, tsConfigNames, excludeInReferences, }) {
|
|
32
36
|
const packageJson = fs_1.default
|
|
33
37
|
.readFileSync(path_1.default.resolve(packageDir, './package.json'))
|
|
34
38
|
.toString();
|
|
@@ -46,7 +50,9 @@ function processPackage(packageDir, allPackages, packageData, tsConfigNames) {
|
|
|
46
50
|
...Object.keys(packageJsonData.devDependencies || {}),
|
|
47
51
|
]
|
|
48
52
|
// all dependencies that are workspace dependencies and have a tsconfig.json
|
|
49
|
-
.map((dependencyData) => allPackages.find((packageData) => packageData.name === dependencyData))
|
|
53
|
+
.map((dependencyData) => allPackages.find((packageData) => packageData.name === dependencyData))
|
|
54
|
+
// remove packages that should be excluded in references
|
|
55
|
+
.filter((packageData) => packageData && excludeInReferences.indexOf(packageData.name) === -1), tsConfigNames);
|
|
50
56
|
// Exit early if references are unchanged (using JSON for deep comparison)
|
|
51
57
|
if (JSON.stringify(oldReferences) === JSON.stringify(newReferences)) {
|
|
52
58
|
return 'success';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updatePackageProjectReferences.js","sourceRoot":"","sources":["../../src/updatePackageProjectReferences.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,iDAAyC;AACzC,+CAKuB;AACvB,gDAAwB;AAIjB,MAAM,8BAA8B,GAAG,
|
|
1
|
+
{"version":3,"file":"updatePackageProjectReferences.js","sourceRoot":"","sources":["../../src/updatePackageProjectReferences.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,iDAAyC;AACzC,+CAKuB;AACvB,gDAAwB;AAIjB,MAAM,8BAA8B,GAAG,CAAC,EAC7C,aAAa,EACb,mBAAmB,GAIpB,EAAQ,EAAE;IACT,MAAM,MAAM,GAAG,IAAA,wBAAQ,EAAC,6BAA6B,CAAC,CAAC,QAAQ,EAAE,CAAC;IAElE,MAAM,WAAW,GAAG,IAAA,yBAAW,EAAC,MAAM,CAAC,CAAC;IAExC,IAAI,SAAS,GAAG,IAAI,CAAC;IACrB,KAAK,MAAM,WAAW,IAAI,WAAW,EAAE;QACrC,MAAM,UAAU,GAAG,WAAW,CAAC,IAAI,CAAC;QAEpC,IAAI,YAAE,CAAC,UAAU,CAAC,cAAI,CAAC,OAAO,CAAC,UAAU,EAAE,iBAAiB,CAAC,CAAC,EAAE;YAC9D,SAAS;gBACP,cAAc,CAAC;oBACb,UAAU;oBACV,WAAW;oBACX,aAAa;oBACb,mBAAmB;iBACpB,CAAC,KAAK,SAAS,IAAI,SAAS,CAAC;SACjC;aAAM;YACL,OAAO,CAAC,GAAG,CAAC,oBAAoB,UAAU,EAAE,CAAC,CAAC;SAC/C;KACF;IACD,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;KAC1D;AACH,CAAC,CAAC;AA9BW,QAAA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,aAAa,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE;YACnE,OAAO,SAAS,CAAC;SAClB;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAC5B;YACE,GAAG,YAAY;YACf,6CAA6C;YAC7C,UAAU,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;SAC7D,EACD,IAAI,EACJ,CAAC,CACF,CAAC;QAEF,kDAAkD;QAClD,IAAI,aAAa,CAAC,MAAM,EAAE;YACxB,OAAO,CAAC,GAAG,CACT,kCAAkC,YAAY,MAAM;gBAClD,aAAa,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CACjE,CAAC;SACH;aAAM;YACL,OAAO,CAAC,GAAG,CAAC,kCAAkC,YAAY,EAAE,CAAC,CAAC;SAC/D;QACD,YAAE,CAAC,aAAa,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACxC,OAAO,SAAS,CAAC;KAClB;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,0BAA0B,YAAY,KAAK,CAAC,EAAE,CAAC,CAAC;QAC9D,OAAO,SAAS,CAAC;KAClB;AACH,CAAC"}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export declare const updateRootProjectReferences: (tsConfigNames
|
|
1
|
+
export declare const updateRootProjectReferences: ({ tsConfigNames, excludeProjects, }: {
|
|
2
|
+
tsConfigNames: string[];
|
|
3
|
+
excludeProjects: string[];
|
|
4
|
+
}) => void;
|
|
2
5
|
//# sourceMappingURL=updateRootProjectReferences.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateRootProjectReferences.d.ts","sourceRoot":"","sources":["../../src/updateRootProjectReferences.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,2BAA2B,
|
|
1
|
+
{"version":3,"file":"updateRootProjectReferences.d.ts","sourceRoot":"","sources":["../../src/updateRootProjectReferences.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,2BAA2B;mBAIvB,MAAM,EAAE;qBACN,MAAM,EAAE;MACvB,IAqDH,CAAC"}
|
|
@@ -7,19 +7,19 @@ exports.updateRootProjectReferences = void 0;
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const child_process_1 = require("child_process");
|
|
9
9
|
const sharedUtils_1 = require("./sharedUtils");
|
|
10
|
-
const updateRootProjectReferences = (tsConfigNames) => {
|
|
10
|
+
const updateRootProjectReferences = ({ tsConfigNames, excludeProjects, }) => {
|
|
11
11
|
const cmdRes = (0, child_process_1.execSync)('yarn workspaces list --json').toString();
|
|
12
12
|
const allPackages = (0, sharedUtils_1.getPackages)(cmdRes);
|
|
13
13
|
const tsConfigPath = (0, sharedUtils_1.getTsConfigPath)('.', tsConfigNames);
|
|
14
14
|
if (!tsConfigPath) {
|
|
15
|
-
console.
|
|
15
|
+
console.error('No root-level tsconfig.json found');
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
try {
|
|
19
19
|
const tsConfig = fs_1.default.readFileSync(tsConfigPath).toString();
|
|
20
20
|
const tsConfigData = JSON.parse(tsConfig);
|
|
21
21
|
const oldReferences = tsConfigData.references;
|
|
22
|
-
const newReferences = (0, sharedUtils_1.makeReferences)('.', allPackages, tsConfigNames);
|
|
22
|
+
const newReferences = (0, sharedUtils_1.makeReferences)('.', allPackages.filter((packageData) => excludeProjects.indexOf(packageData.name) === -1), tsConfigNames);
|
|
23
23
|
// Don't continue if references are unchanged
|
|
24
24
|
if (JSON.stringify(newReferences) === JSON.stringify(oldReferences)) {
|
|
25
25
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateRootProjectReferences.js","sourceRoot":"","sources":["../../src/updateRootProjectReferences.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;A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U,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS;SAC7D,EACD,IAAI,EACJ,CAAC,CACF,CAAC;QAEF,IAAI,aAAa,CAAC,MAAM,EAAE;YACxB,OAAO,CAAC,GAAG,CACT,kCAAkC,YAAY,MAAM;gBAClD,aAAa,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CACjE,CAAC;SACH;aAAM;YACL,OAAO,CAAC,GAAG,CAAC,kCAAkC,YAAY,EAAE,CAAC,CAAC;SAC/D;QACD,YAAE,CAAC,aAAa,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;KAC5C;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CACX,gDAAgD,YAAY,MAAM,CAAC,EAAE,CACtE,CAAC;QACF,MAAM,CAAC,CAAC;KACT;AACH,CAAC,CAAC;AA3DW,QAAA,2BAA2B,+BA2DtC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const run: (args: string[]) => void
|
|
1
|
+
export declare const run: (args: string[]) => Promise<void>;
|
|
2
2
|
//# sourceMappingURL=utilsTypeScriptReferences.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilsTypeScriptReferences.d.ts","sourceRoot":"","sources":["../../src/utilsTypeScriptReferences.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utilsTypeScriptReferences.d.ts","sourceRoot":"","sources":["../../src/utilsTypeScriptReferences.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,GAAG,SAAgB,MAAM,EAAE,KAAG,QAAQ,IAAI,CAoEtD,CAAC"}
|
|
@@ -1,43 +1,74 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.run = void 0;
|
|
4
7
|
const updatePackageProjectReferences_1 = require("./updatePackageProjectReferences");
|
|
5
8
|
const updateRootProjectReferences_1 = require("./updateRootProjectReferences");
|
|
6
|
-
const
|
|
9
|
+
const yargs_1 = __importDefault(require("yargs"));
|
|
10
|
+
const run = async (args) => {
|
|
11
|
+
var _a;
|
|
12
|
+
const argv = await yargs_1.default
|
|
13
|
+
.scriptName('utils-typescript-references')
|
|
14
|
+
.version('0.2.0')
|
|
15
|
+
.option('skipPackages', {
|
|
16
|
+
description: 'Only update project references in the root tsConfig',
|
|
17
|
+
type: 'boolean',
|
|
18
|
+
})
|
|
19
|
+
.option('skipRoot', {
|
|
20
|
+
description: 'Skip updating project references in project root tsConfig',
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
})
|
|
23
|
+
.option('excludeInReferences', {
|
|
24
|
+
type: 'array',
|
|
25
|
+
description: 'Exclude specific packages from being referenced by other packages',
|
|
26
|
+
})
|
|
27
|
+
.option('excludeInRoot', {
|
|
28
|
+
type: 'array',
|
|
29
|
+
description: 'Exclude specific packages from being referenced in the root tsConfig',
|
|
30
|
+
})
|
|
31
|
+
.option('tsConfigName', {
|
|
32
|
+
type: 'array',
|
|
33
|
+
description: 'Names of tsConfig files to be updated',
|
|
34
|
+
})
|
|
35
|
+
.parse();
|
|
7
36
|
const options = {
|
|
8
37
|
tsConfigNames: [],
|
|
38
|
+
excludeInReferences: [],
|
|
39
|
+
excludeInRoot: [],
|
|
9
40
|
skipPackages: false,
|
|
10
41
|
skipRoot: false,
|
|
11
42
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
else if (arg === '--tsConfigName') {
|
|
24
|
-
argFallback = (arg) => {
|
|
25
|
-
options.tsConfigNames.push(arg);
|
|
26
|
-
argFallback = defaultArgFallback;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
argFallback(arg);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (!options.tsConfigNames.length) {
|
|
43
|
+
if (argv.skipPackages) {
|
|
44
|
+
options.skipPackages = true;
|
|
45
|
+
}
|
|
46
|
+
if (argv.skipRoot) {
|
|
47
|
+
options.skipRoot = true;
|
|
48
|
+
}
|
|
49
|
+
if (argv.tsConfigName && ((_a = argv.tsConfigName) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
50
|
+
options.tsConfigNames = argv.tsConfigName;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
34
53
|
options.tsConfigNames.push('tsconfig.json');
|
|
35
54
|
}
|
|
55
|
+
if (argv.excludeInReferences) {
|
|
56
|
+
options.excludeInReferences = argv.excludeInReferences;
|
|
57
|
+
}
|
|
58
|
+
if (argv.excludeInRoot) {
|
|
59
|
+
options.excludeInRoot = argv.excludeInRoot;
|
|
60
|
+
}
|
|
36
61
|
if (!options.skipPackages) {
|
|
37
|
-
(0, updatePackageProjectReferences_1.updatePackageProjectReferences)(
|
|
62
|
+
(0, updatePackageProjectReferences_1.updatePackageProjectReferences)({
|
|
63
|
+
tsConfigNames: options.tsConfigNames,
|
|
64
|
+
excludeInReferences: options.excludeInReferences,
|
|
65
|
+
});
|
|
38
66
|
}
|
|
39
67
|
if (!options.skipRoot) {
|
|
40
|
-
(0, updateRootProjectReferences_1.updateRootProjectReferences)(
|
|
68
|
+
(0, updateRootProjectReferences_1.updateRootProjectReferences)({
|
|
69
|
+
tsConfigNames: options.tsConfigNames,
|
|
70
|
+
excludeProjects: options.excludeInRoot,
|
|
71
|
+
});
|
|
41
72
|
}
|
|
42
73
|
};
|
|
43
74
|
exports.run = run;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilsTypeScriptReferences.js","sourceRoot":"","sources":["../../src/utilsTypeScriptReferences.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utilsTypeScriptReferences.js","sourceRoot":"","sources":["../../src/utilsTypeScriptReferences.ts"],"names":[],"mappings":";;;;;;AAAA,qFAAkF;AAClF,+EAA4E;AAE5E,kDAAoC;AAU7B,MAAM,GAAG,GAAG,KAAK,EAAE,IAAc,EAAiB,EAAE;;IACzD,MAAM,IAAI,GAAG,MAAM,eAAK;SACrB,UAAU,CAAC,6BAA6B,CAAC;SACzC,OAAO,CAAC,OAAO,CAAC;SAChB,MAAM,CAAC,cAAc,EAAE;QACtB,WAAW,EAAE,qDAAqD;QAClE,IAAI,EAAE,SAAS;KAChB,CAAC;SACD,MAAM,CAAC,UAAU,EAAE;QAClB,WAAW,EAAE,2DAA2D;QACxE,IAAI,EAAE,SAAS;KAChB,CAAC;SACD,MAAM,CAAC,qBAAqB,EAAE;QAC7B,IAAI,EAAE,OAAO;QACb,WAAW,EACT,mEAAmE;KACtE,CAAC;SACD,MAAM,CAAC,eAAe,EAAE;QACvB,IAAI,EAAE,OAAO;QACb,WAAW,EACT,sEAAsE;KACzE,CAAC;SACD,MAAM,CAAC,cAAc,EAAE;QACtB,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,uCAAuC;KACrD,CAAC;SACD,KAAK,EAAE,CAAC;IAEX,MAAM,OAAO,GAAe;QAC1B,aAAa,EAAE,EAAE;QACjB,mBAAmB,EAAE,EAAE;QACvB,aAAa,EAAE,EAAE;QACjB,YAAY,EAAE,KAAK;QACnB,QAAQ,EAAE,KAAK;KAChB,CAAC;IAEF,IAAI,IAAI,CAAC,YAAY,EAAE;QACrB,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;KAC7B;IACD,IAAI,IAAI,CAAC,QAAQ,EAAE;QACjB,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;KACzB;IAED,IAAI,IAAI,CAAC,YAAY,IAAI,CAAA,MAAA,IAAI,CAAC,YAAY,0CAAE,MAAM,IAAG,CAAC,EAAE;QACtD,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,YAAwB,CAAC;KACvD;SAAM;QACL,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;KAC7C;IAED,IAAI,IAAI,CAAC,mBAAmB,EAAE;QAC5B,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAA+B,CAAC;KACpE;IACD,IAAI,IAAI,CAAC,aAAa,EAAE;QACtB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,aAAyB,CAAC;KACxD;IACD,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE;QACzB,IAAA,+DAA8B,EAAC;YAC7B,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;SACjD,CAAC,CAAC;KACJ;IAED,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;QACrB,IAAA,yDAA2B,EAAC;YAC1B,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,eAAe,EAAE,OAAO,CAAC,aAAa;SACvC,CAAC,CAAC;KACJ;AACH,CAAC,CAAC;AApEW,QAAA,GAAG,OAoEd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goldstack/utils-typescript-references",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Utility for keeping TypeScript references in sync in a Yarn monorepo",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"goldstack",
|
|
@@ -35,13 +35,15 @@
|
|
|
35
35
|
"version:apply:force": "yarn version $@ && yarn version apply"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"source-map-support": "^0.5.21"
|
|
38
|
+
"source-map-support": "^0.5.21",
|
|
39
|
+
"yargs": "^17.5.1"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
|
-
"@goldstack/utils-git": "0.1.
|
|
42
|
+
"@goldstack/utils-git": "0.1.35",
|
|
42
43
|
"@types/jest": "^27.5.1",
|
|
43
44
|
"@types/node": "^17.0.33",
|
|
44
45
|
"@types/source-map-support": "^0.5.4",
|
|
46
|
+
"@types/yargs": "^17.0.10",
|
|
45
47
|
"jest": "^28.1.0",
|
|
46
48
|
"rimraf": "^3.0.2",
|
|
47
49
|
"ts-jest": "^28.0.2",
|