@yarn-tool/fix-all 1.0.1
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/CHANGELOG.md +17 -0
- package/README.md +12 -0
- package/index.d.ts +7 -0
- package/index.js +54 -0
- package/index.js.map +1 -0
- package/lib/pkg/index.d.ts +23 -0
- package/lib/pkg/index.js +69 -0
- package/lib/pkg/index.js.map +1 -0
- package/lib/root/index.d.ts +21 -0
- package/lib/root/index.js +56 -0
- package/lib/root/index.js.map +1 -0
- package/lib/util/cli-progress.d.ts +2 -0
- package/lib/util/cli-progress.js +19 -0
- package/lib/util/cli-progress.js.map +1 -0
- package/package.json +79 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## 1.0.1 (2021-12-29)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ✨ Features
|
|
10
|
+
|
|
11
|
+
* sort-package-json ([f4d5aeb](https://github.com/bluelovers/ws-yarn-workspaces/commit/f4d5aebd088b1887781fb225fb5022266d80012f))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### 🔖 Miscellaneous
|
|
15
|
+
|
|
16
|
+
* . ([4c696ff](https://github.com/bluelovers/ws-yarn-workspaces/commit/4c696ffe958b9177b75c8c79a3ca9bf0d639ed64))
|
|
17
|
+
* `@yarn-tool/fix-all` ([e89b9a1](https://github.com/bluelovers/ws-yarn-workspaces/commit/e89b9a1ec6493f63fba37b3bf9a4dbc2bee99966))
|
package/README.md
ADDED
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.npmAutoFixAll = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const find_root_1 = require("@yarn-tool/find-root");
|
|
6
|
+
const pkg_git_info_1 = require("@yarn-tool/pkg-git-info");
|
|
7
|
+
const index_1 = require("./lib/root/index");
|
|
8
|
+
const index_2 = require("./lib/pkg/index");
|
|
9
|
+
const logger_1 = require("debug-color2/logger");
|
|
10
|
+
const bluebird_1 = tslib_1.__importDefault(require("bluebird"));
|
|
11
|
+
function npmAutoFixAll(cwd, options) {
|
|
12
|
+
return bluebird_1.default.resolve().then(() => {
|
|
13
|
+
cwd !== null && cwd !== void 0 ? cwd : (cwd = process.cwd());
|
|
14
|
+
logger_1.consoleLogger.info(`cwd: ${cwd}`);
|
|
15
|
+
const rootData = (0, find_root_1.findRootLazy)({
|
|
16
|
+
cwd,
|
|
17
|
+
});
|
|
18
|
+
if (!(rootData === null || rootData === void 0 ? void 0 : rootData.root)) {
|
|
19
|
+
throw new Error(`Invalid workspaces / package: ${cwd}`);
|
|
20
|
+
}
|
|
21
|
+
console.log(`root:`, rootData.root);
|
|
22
|
+
console.log(`hasWorkspace:`, rootData.hasWorkspace);
|
|
23
|
+
let { branch, overwriteHostedGitInfo } = options !== null && options !== void 0 ? options : {};
|
|
24
|
+
cwd = rootData.cwd;
|
|
25
|
+
logger_1.consoleLogger.info(`check git info`);
|
|
26
|
+
const hostedGitInfo = (0, pkg_git_info_1.npmHostedGitInfoLazy)(cwd);
|
|
27
|
+
console.log(`homepage:`, hostedGitInfo.homepage);
|
|
28
|
+
console.log(`repository:`, hostedGitInfo.repository);
|
|
29
|
+
logger_1.consoleLogger.info(`auto fix root of workspaces / package`);
|
|
30
|
+
console.log(`root:`, rootData.root);
|
|
31
|
+
if (rootData.hasWorkspace) {
|
|
32
|
+
(0, index_1._fixWsRoot)({
|
|
33
|
+
rootData,
|
|
34
|
+
hostedGitInfo,
|
|
35
|
+
branch,
|
|
36
|
+
overwriteHostedGitInfo,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
(0, index_1._fixRoot)({
|
|
41
|
+
rootData,
|
|
42
|
+
hostedGitInfo,
|
|
43
|
+
branch,
|
|
44
|
+
overwriteHostedGitInfo,
|
|
45
|
+
targetDir: rootData.root,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const list = (0, index_2._initPkgListableByRootData)(rootData);
|
|
49
|
+
return (0, index_2._runEachPackagesAsync)(list, rootData);
|
|
50
|
+
}).then(() => void 0);
|
|
51
|
+
}
|
|
52
|
+
exports.npmAutoFixAll = npmAutoFixAll;
|
|
53
|
+
exports.default = npmAutoFixAll;
|
|
54
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;AAAA,oDAAoD;AACpD,0DAA+D;AAC/D,4CAAwD;AACxD,2CAAoF;AACpF,gDAAoD;AACpD,gEAAgC;AAQhC,SAAgB,aAAa,CAAC,GAAW,EAAE,OAAwB;IAElE,OAAO,kBAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;QAEnC,GAAG,aAAH,GAAG,cAAH,GAAG,IAAH,GAAG,GAAK,OAAO,CAAC,GAAG,EAAE,EAAC;QAEtB,sBAAa,CAAC,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC;QAElC,MAAM,QAAQ,GAAG,IAAA,wBAAY,EAAC;YAC7B,GAAG;SACH,CAAC,CAAC;QAEH,IAAI,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,CAAA,EACnB;YACC,MAAM,IAAI,KAAK,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAA;SACvD;QAED,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;QAEpD,IAAI,EAAE,MAAM,EAAE,sBAAsB,EAAE,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;QAEvD,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;QAEnB,sBAAa,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QAErC,MAAM,aAAa,GAAG,IAAA,mCAAoB,EAAC,GAAG,CAAC,CAAC;QAEhD,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;QACjD,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;QAErD,sBAAa,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;QAE5D,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEpC,IAAI,QAAQ,CAAC,YAAY,EACzB;YACC,IAAA,kBAAU,EAAC;gBACV,QAAQ;gBACR,aAAa;gBACb,MAAM;gBACN,sBAAsB;aACtB,CAAC,CAAA;SACF;aAED;YACC,IAAA,gBAAQ,EAAC;gBACR,QAAQ;gBACR,aAAa;gBACb,MAAM;gBACN,sBAAsB;gBACtB,SAAS,EAAE,QAAQ,CAAC,IAAI;aACxB,CAAC,CAAA;SACF;QAED,MAAM,IAAI,GAAG,IAAA,kCAA0B,EAAC,QAAQ,CAAC,CAAC;QAElD,OAAO,IAAA,6BAAqB,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IAC7C,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAS,CAAC,CAAA;AAC9B,CAAC;AA3DD,sCA2DC;AAED,kBAAe,aAAa,CAAA","sourcesContent":["import { findRootLazy } from '@yarn-tool/find-root';\nimport { npmHostedGitInfoLazy } from '@yarn-tool/pkg-git-info';\nimport { _fixRoot, _fixWsRoot } from './lib/root/index';\nimport { _initPkgListableByRootData, _runEachPackagesAsync } from './lib/pkg/index';\nimport { consoleLogger } from 'debug-color2/logger';\nimport Bluebird from 'bluebird';\n\nexport interface INpmAutoFixAll\n{\n\toverwriteHostedGitInfo?: boolean;\n\tbranch?: string;\n}\n\nexport function npmAutoFixAll(cwd: string, options?: INpmAutoFixAll)\n{\n\treturn Bluebird.resolve().then(() =>\n\t{\n\t\tcwd ??= process.cwd();\n\n\t\tconsoleLogger.info(`cwd: ${cwd}`);\n\n\t\tconst rootData = findRootLazy({\n\t\t\tcwd,\n\t\t});\n\n\t\tif (!rootData?.root)\n\t\t{\n\t\t\tthrow new Error(`Invalid workspaces / package: ${cwd}`)\n\t\t}\n\n\t\tconsole.log(`root:`, rootData.root);\n\t\tconsole.log(`hasWorkspace:`, rootData.hasWorkspace);\n\n\t\tlet { branch, overwriteHostedGitInfo } = options ?? {};\n\n\t\tcwd = rootData.cwd;\n\n\t\tconsoleLogger.info(`check git info`);\n\n\t\tconst hostedGitInfo = npmHostedGitInfoLazy(cwd);\n\n\t\tconsole.log(`homepage:`, hostedGitInfo.homepage);\n\t\tconsole.log(`repository:`, hostedGitInfo.repository);\n\n\t\tconsoleLogger.info(`auto fix root of workspaces / package`);\n\n\t\tconsole.log(`root:`, rootData.root);\n\n\t\tif (rootData.hasWorkspace)\n\t\t{\n\t\t\t_fixWsRoot({\n\t\t\t\trootData,\n\t\t\t\thostedGitInfo,\n\t\t\t\tbranch,\n\t\t\t\toverwriteHostedGitInfo,\n\t\t\t})\n\t\t}\n\t\telse\n\t\t{\n\t\t\t_fixRoot({\n\t\t\t\trootData,\n\t\t\t\thostedGitInfo,\n\t\t\t\tbranch,\n\t\t\t\toverwriteHostedGitInfo,\n\t\t\t\ttargetDir: rootData.root,\n\t\t\t})\n\t\t}\n\n\t\tconst list = _initPkgListableByRootData(rootData);\n\n\t\treturn _runEachPackagesAsync(list, rootData)\n\t}).then(() => void 0 as void)\n}\n\nexport default npmAutoFixAll\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IOptionsPkgListable } from 'ws-pkg-list';
|
|
2
|
+
import { IFindRootReturnType } from '@yarn-tool/find-root';
|
|
3
|
+
import Bluebird from 'bluebird';
|
|
4
|
+
export declare function _handler(cwd: string, ...argv: Parameters<IOptionsPkgListable["handler"]>): {
|
|
5
|
+
pkg: import("@ts-type/package-dts").IPackageJson<any>;
|
|
6
|
+
manifestLocation: string;
|
|
7
|
+
name: string;
|
|
8
|
+
version: string;
|
|
9
|
+
private: boolean;
|
|
10
|
+
location: string;
|
|
11
|
+
prefix: string;
|
|
12
|
+
};
|
|
13
|
+
export declare type IEntry = ReturnType<typeof _handler>;
|
|
14
|
+
export declare function _runEachPackagesAsync(list: IEntry[], rootData: IFindRootReturnType): Bluebird<void[]>;
|
|
15
|
+
export declare function _initPkgListableByRootData(rootData: Pick<IFindRootReturnType, 'root' | 'hasWorkspace'>): {
|
|
16
|
+
pkg: import("@ts-type/package-dts").IPackageJson<any>;
|
|
17
|
+
manifestLocation: string;
|
|
18
|
+
name: string;
|
|
19
|
+
version: string;
|
|
20
|
+
private: boolean;
|
|
21
|
+
location: string;
|
|
22
|
+
prefix: string;
|
|
23
|
+
}[];
|
package/lib/pkg/index.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._initPkgListableByRootData = exports._runEachPackagesAsync = exports._handler = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const ws_pkg_list_1 = require("ws-pkg-list");
|
|
6
|
+
const npm_package_json_loader_1 = require("npm-package-json-loader");
|
|
7
|
+
const pkg_entry_util_1 = require("@yarn-tool/pkg-entry-util");
|
|
8
|
+
const lazy_aggregate_error_1 = require("lazy-aggregate-error");
|
|
9
|
+
const bluebird_1 = tslib_1.__importDefault(require("bluebird"));
|
|
10
|
+
const cli_progress_1 = require("../util/cli-progress");
|
|
11
|
+
const logger_1 = require("debug-color2/logger");
|
|
12
|
+
const debug_color2_1 = require("debug-color2");
|
|
13
|
+
function _handler(cwd, ...argv) {
|
|
14
|
+
return {
|
|
15
|
+
...(0, ws_pkg_list_1.normalizeListableRowExtra)(argv[0], cwd),
|
|
16
|
+
pkg: argv[1],
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports._handler = _handler;
|
|
20
|
+
function _runEachPackagesAsync(list, rootData) {
|
|
21
|
+
let logger;
|
|
22
|
+
return bluebird_1.default.resolve(list)
|
|
23
|
+
.tap(() => {
|
|
24
|
+
logger = (0, cli_progress_1.createProgressEstimator)(rootData.root);
|
|
25
|
+
logger_1.consoleLogger.info(`auto check/fix packages`);
|
|
26
|
+
})
|
|
27
|
+
.mapSeries(async (row) => {
|
|
28
|
+
//console.dir(row);
|
|
29
|
+
const err = new lazy_aggregate_error_1.AggregateErrorExtra();
|
|
30
|
+
const promiseLogger = logger((async () => {
|
|
31
|
+
const pkg = new npm_package_json_loader_1.PackageJsonLoader(row.manifestLocation);
|
|
32
|
+
try {
|
|
33
|
+
(0, pkg_entry_util_1.pkgExportsVerify)(pkg.data);
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
err.push(e);
|
|
37
|
+
}
|
|
38
|
+
pkg.autofix();
|
|
39
|
+
pkg.write();
|
|
40
|
+
})().catch(e => err.push(e)), row.name);
|
|
41
|
+
return promiseLogger
|
|
42
|
+
.catch(e => err.push(e))
|
|
43
|
+
.then(() => {
|
|
44
|
+
if (err.length) {
|
|
45
|
+
debug_color2_1.console.error(err.toString());
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
exports._runEachPackagesAsync = _runEachPackagesAsync;
|
|
51
|
+
function _initPkgListableByRootData(rootData) {
|
|
52
|
+
let cwd = rootData.root;
|
|
53
|
+
if (rootData.hasWorkspace) {
|
|
54
|
+
return (0, ws_pkg_list_1.wsPkgListable)(cwd, {
|
|
55
|
+
handler(...argv) {
|
|
56
|
+
return _handler(cwd, ...argv);
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return (0, ws_pkg_list_1.wsPkgListableFromPaths)([
|
|
61
|
+
cwd,
|
|
62
|
+
], cwd, {
|
|
63
|
+
handler(...argv) {
|
|
64
|
+
return _handler(cwd, ...argv);
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
exports._initPkgListableByRootData = _initPkgListableByRootData;
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;AAAA,6CAAoH;AAEpH,qEAA4D;AAC5D,8DAA6D;AAC7D,+DAA2D;AAC3D,gEAAgC;AAChC,uDAA+D;AAC/D,gDAAoD;AACpD,+CAAuC;AAGvC,SAAgB,QAAQ,CAAC,GAAW,EAAE,GAAG,IAAgD;IAExF,OAAO;QACN,GAAG,IAAA,uCAAyB,EAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;QAC1C,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;KACZ,CAAA;AACF,CAAC;AAND,4BAMC;AAID,SAAgB,qBAAqB,CAAC,IAAc,EAAE,QAA6B;IAElF,IAAI,MAAyB,CAAC;IAE9B,OAAO,kBAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;SAC3B,GAAG,CAAC,GAAG,EAAE;QAET,MAAM,GAAG,IAAA,sCAAuB,EAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEhD,sBAAa,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAC/C,CAAC,CAAC;SACD,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAExB,mBAAmB;QAEnB,MAAM,GAAG,GAAG,IAAI,0CAAmB,EAAE,CAAC;QAEtC,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC,KAAK,IAAI,EAAE;YAGxC,MAAM,GA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;AAtBD,gEAsBC","sourcesContent":["import { IOptionsPkgListable, normalizeListableRowExtra, wsPkgListable, wsPkgListableFromPaths } from 'ws-pkg-list';\nimport { IFindRootReturnType } from '@yarn-tool/find-root';\nimport { PackageJsonLoader } from 'npm-package-json-loader';\nimport { pkgExportsVerify } from '@yarn-tool/pkg-entry-util';\nimport { AggregateErrorExtra } from 'lazy-aggregate-error';\nimport Bluebird from 'bluebird';\nimport { createProgressEstimator } from '../util/cli-progress';\nimport { consoleLogger } from 'debug-color2/logger';\nimport { console } from 'debug-color2';\nimport { ProgressEstimator } from 'progress-estimator';\n\nexport function _handler(cwd: string, ...argv: Parameters<IOptionsPkgListable[\"handler\"]>)\n{\n\treturn {\n\t\t...normalizeListableRowExtra(argv[0], cwd),\n\t\tpkg: argv[1],\n\t}\n}\n\nexport type IEntry = ReturnType<typeof _handler>\n\nexport function _runEachPackagesAsync(list: IEntry[], rootData: IFindRootReturnType)\n{\n\tlet logger: ProgressEstimator;\n\n\treturn Bluebird.resolve(list)\n\t\t.tap(() =>\n\t\t{\n\t\t\tlogger = createProgressEstimator(rootData.root);\n\n\t\t\tconsoleLogger.info(`auto check/fix packages`);\n\t\t})\n\t\t.mapSeries(async (row) =>\n\t\t{\n\t\t\t//console.dir(row);\n\n\t\t\tconst err = new AggregateErrorExtra();\n\n\t\t\tconst promiseLogger = logger((async () =>\n\t\t\t{\n\n\t\t\t\tconst pkg = new PackageJsonLoader(row.manifestLocation);\n\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tpkgExportsVerify(pkg.data);\n\t\t\t\t}\n\t\t\t\tcatch (e)\n\t\t\t\t{\n\t\t\t\t\terr.push(e);\n\t\t\t\t}\n\n\t\t\t\tpkg.autofix();\n\t\t\t\tpkg.write();\n\n\t\t\t})().catch(e => err.push(e)), row.name)\n\n\t\t\treturn promiseLogger\n\t\t\t\t.catch(e => err.push(e))\n\t\t\t\t.then(() =>\n\t\t\t\t{\n\t\t\t\t\tif (err.length)\n\t\t\t\t\t{\n\t\t\t\t\t\tconsole.error(err.toString());\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t})\n\t\t;\n}\n\nexport function _initPkgListableByRootData(rootData: Pick<IFindRootReturnType, 'root' | 'hasWorkspace'>)\n{\n\tlet cwd = rootData.root;\n\n\tif (rootData.hasWorkspace)\n\t{\n\t\treturn wsPkgListable(cwd, {\n\t\t\thandler(...argv)\n\t\t\t{\n\t\t\t\treturn _handler(cwd, ...argv)\n\t\t\t},\n\t\t})\n\t}\n\n\treturn wsPkgListableFromPaths([\n\t\tcwd,\n\t], cwd, {\n\t\thandler(...argv)\n\t\t{\n\t\t\treturn _handler(cwd, ...argv)\n\t\t},\n\t})\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ITSRequiredPick } from 'ts-type/lib/type/record';
|
|
2
|
+
import { IFillPkgHostedInfoOptions } from '@yarn-tool/pkg-hosted-info';
|
|
3
|
+
import { PackageJsonLoader } from 'npm-package-json-loader';
|
|
4
|
+
export declare function _fixRoot(options: Required<IFillPkgHostedInfoOptions>): {
|
|
5
|
+
root_file_package_json: string;
|
|
6
|
+
root_pkg_json: PackageJsonLoader<import("@ts-type/package-dts").IPackageJson<any>>;
|
|
7
|
+
targetDir: string;
|
|
8
|
+
rootData: import("@yarn-tool/find-root").IFindRootReturnType;
|
|
9
|
+
hostedGitInfo: import("@yarn-tool/pkg-git-info").INpmHostedGitInfo;
|
|
10
|
+
branch: string;
|
|
11
|
+
overwriteHostedGitInfo: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function _fixWsRoot(options: ITSRequiredPick<IFillPkgHostedInfoOptions, 'hostedGitInfo' | 'rootData' | 'overwriteHostedGitInfo' | 'branch'>): {
|
|
14
|
+
root_file_package_json: string;
|
|
15
|
+
root_pkg_json: PackageJsonLoader<import("@ts-type/package-dts").IPackageJson<any>>;
|
|
16
|
+
targetDir: string;
|
|
17
|
+
rootData: import("@yarn-tool/find-root").IFindRootReturnType;
|
|
18
|
+
hostedGitInfo: import("@yarn-tool/pkg-git-info").INpmHostedGitInfo;
|
|
19
|
+
branch: string;
|
|
20
|
+
overwriteHostedGitInfo: boolean;
|
|
21
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._fixWsRoot = exports._fixRoot = void 0;
|
|
4
|
+
const pkg_hosted_info_1 = require("@yarn-tool/pkg-hosted-info");
|
|
5
|
+
const upath2_1 = require("upath2");
|
|
6
|
+
const pkg_git_info_1 = require("@yarn-tool/pkg-git-info");
|
|
7
|
+
const npm_package_json_loader_1 = require("npm-package-json-loader");
|
|
8
|
+
const ws_scope_1 = require("@yarn-tool/ws-scope");
|
|
9
|
+
const sort_package_json3_1 = require("sort-package-json3");
|
|
10
|
+
function _fixRoot(options) {
|
|
11
|
+
let { rootData, branch, overwriteHostedGitInfo, hostedGitInfo, targetDir } = options;
|
|
12
|
+
const root_file_package_json = (0, upath2_1.join)(targetDir, 'package.json');
|
|
13
|
+
let root_pkg_json = new npm_package_json_loader_1.PackageJsonLoader(root_file_package_json);
|
|
14
|
+
hostedGitInfo !== null && hostedGitInfo !== void 0 ? hostedGitInfo : (hostedGitInfo = (0, pkg_git_info_1.npmHostedGitInfoLazy)());
|
|
15
|
+
if (hostedGitInfo) {
|
|
16
|
+
(0, pkg_hosted_info_1.fillPkgHostedInfo)(root_pkg_json.data, {
|
|
17
|
+
targetDir,
|
|
18
|
+
rootData,
|
|
19
|
+
hostedGitInfo,
|
|
20
|
+
branch,
|
|
21
|
+
overwriteHostedGitInfo,
|
|
22
|
+
});
|
|
23
|
+
root_pkg_json.data = (0, sort_package_json3_1.sortPackageJson)(root_pkg_json.data);
|
|
24
|
+
root_pkg_json.write();
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
root_file_package_json,
|
|
28
|
+
root_pkg_json,
|
|
29
|
+
targetDir,
|
|
30
|
+
rootData,
|
|
31
|
+
hostedGitInfo,
|
|
32
|
+
branch,
|
|
33
|
+
overwriteHostedGitInfo,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
exports._fixRoot = _fixRoot;
|
|
37
|
+
function _fixWsRoot(options) {
|
|
38
|
+
var _a, _b, _c;
|
|
39
|
+
if (!((_a = options.rootData.ws) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
40
|
+
throw new Error(`Invalid workspaces`);
|
|
41
|
+
}
|
|
42
|
+
let runtime = _fixRoot({
|
|
43
|
+
...options,
|
|
44
|
+
targetDir: options.rootData.ws,
|
|
45
|
+
});
|
|
46
|
+
if (((_b = runtime.hostedGitInfo) === null || _b === void 0 ? void 0 : _b.homepage) && (options === null || options === void 0 ? void 0 : options.overwriteHostedGitInfo)) {
|
|
47
|
+
runtime.root_pkg_json.data.homepage = (_c = runtime.hostedGitInfo) === null || _c === void 0 ? void 0 : _c.homepage;
|
|
48
|
+
runtime.root_pkg_json.write();
|
|
49
|
+
}
|
|
50
|
+
let wss = new ws_scope_1.WorkspacesScope(runtime.rootData.ws);
|
|
51
|
+
wss.syncValue();
|
|
52
|
+
wss.save();
|
|
53
|
+
return runtime;
|
|
54
|
+
}
|
|
55
|
+
exports._fixWsRoot = _fixWsRoot;
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AACA,gEAA0F;AAC1F,mCAA8B;AAC9B,0DAA+D;AAC/D,qEAA4D;AAC5D,kDAAsD;AACtD,2DAAqD;AAErD,SAAgB,QAAQ,CAAC,OAA4C;IAEpE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,sBAAsB,EAAE,aAAa,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAErF,MAAM,sBAAsB,GAAG,IAAA,aAAI,EAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IAE/D,IAAI,aAAa,GAAG,I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,CAAC,IAAI,EAAE,CAAC;IAEX,OAAO,OAAO,CAAA;AACf,CAAC;AAvBD,gCAuBC","sourcesContent":["import { ITSRequiredPick } from 'ts-type/lib/type/record';\nimport { fillPkgHostedInfo, IFillPkgHostedInfoOptions } from '@yarn-tool/pkg-hosted-info';\nimport { join } from 'upath2';\nimport { npmHostedGitInfoLazy } from '@yarn-tool/pkg-git-info';\nimport { PackageJsonLoader } from 'npm-package-json-loader';\nimport { WorkspacesScope } from '@yarn-tool/ws-scope';\nimport { sortPackageJson } from 'sort-package-json3';\n\nexport function _fixRoot(options: Required<IFillPkgHostedInfoOptions>)\n{\n\tlet { rootData, branch, overwriteHostedGitInfo, hostedGitInfo, targetDir } = options;\n\n\tconst root_file_package_json = join(targetDir, 'package.json');\n\n\tlet root_pkg_json = new PackageJsonLoader(root_file_package_json);\n\n\thostedGitInfo ??= npmHostedGitInfoLazy();\n\n\tif (hostedGitInfo)\n\t{\n\t\tfillPkgHostedInfo(root_pkg_json.data, {\n\t\t\ttargetDir,\n\t\t\trootData,\n\t\t\thostedGitInfo,\n\t\t\tbranch,\n\t\t\toverwriteHostedGitInfo,\n\t\t});\n\n\t\troot_pkg_json.data = sortPackageJson(root_pkg_json.data);\n\n\t\troot_pkg_json.write();\n\t}\n\n\treturn {\n\t\troot_file_package_json,\n\t\troot_pkg_json,\n\t\ttargetDir,\n\t\trootData,\n\t\thostedGitInfo,\n\t\tbranch,\n\t\toverwriteHostedGitInfo,\n\t}\n}\n\nexport function _fixWsRoot(options: ITSRequiredPick<IFillPkgHostedInfoOptions, 'hostedGitInfo' | 'rootData' | 'overwriteHostedGitInfo' | 'branch'>)\n{\n\tif (!options.rootData.ws?.length)\n\t{\n\t\tthrow new Error(`Invalid workspaces`)\n\t}\n\n\tlet runtime = _fixRoot({\n\t\t...options,\n\t\ttargetDir: options.rootData.ws,\n\t});\n\n\tif (runtime.hostedGitInfo?.homepage && options?.overwriteHostedGitInfo)\n\t{\n\t\truntime.root_pkg_json.data.homepage = runtime.hostedGitInfo?.homepage;\n\t\truntime.root_pkg_json.write();\n\t}\n\n\tlet wss = new WorkspacesScope(runtime.rootData.ws);\n\twss.syncValue();\n\twss.save();\n\n\treturn runtime\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createProgressEstimator = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs_extra_1 = require("fs-extra");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
const progress_estimator_1 = tslib_1.__importDefault(require("progress-estimator"));
|
|
9
|
+
const findPkgModuleCachePath_1 = require("cache-path/lib/finder/findPkgModuleCachePath");
|
|
10
|
+
function createProgressEstimator(root) {
|
|
11
|
+
const storagePath = (0, path_1.join)((0, findPkgModuleCachePath_1.findPkgModuleCachePathCore)(root), '.progress-estimator');
|
|
12
|
+
(0, fs_extra_1.ensureDirSync)(storagePath);
|
|
13
|
+
return (0, progress_estimator_1.default)({
|
|
14
|
+
// All configuration keys are optional, but it's recommended to specify a storage location.
|
|
15
|
+
storagePath,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
exports.createProgressEstimator = createProgressEstimator;
|
|
19
|
+
//# sourceMappingURL=cli-progress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-progress.js","sourceRoot":"","sources":["cli-progress.ts"],"names":[],"mappings":";;;;AAAA,uCAAyC;AACzC,+BAA4B;AAC5B,aAAa;AACb,oFAAmD;AACnD,yFAAiH;AAEjH,SAAgB,uBAAuB,CAAC,IAAY;IAEnD,MAAM,WAAW,GAAG,IAAA,WAAI,EAAC,IAAA,mDAA0B,EAAC,IAAI,CAAC,EAAE,qBAAqB,CAAC,CAAC;IAClF,IAAA,wBAAa,EAAC,WAAW,CAAC,CAAC;IAC3B,OAAO,IAAA,4BAAiB,EAAC;QACxB,2FAA2F;QAC3F,WAAW;KACX,CAAC,CAAC;AACJ,CAAC;AARD,0DAQC","sourcesContent":["import { ensureDirSync } from 'fs-extra';\nimport { join } from 'path';\n// @ts-ignore\nimport progressEstimator from 'progress-estimator';\nimport { findPkgModuleCachePathCore, findPkgModulePathCore } from 'cache-path/lib/finder/findPkgModuleCachePath';\n\nexport function createProgressEstimator(root: string)\n{\n\tconst storagePath = join(findPkgModuleCachePathCore(root), '.progress-estimator');\n\tensureDirSync(storagePath);\n\treturn progressEstimator({\n\t\t// All configuration keys are optional, but it's recommended to specify a storage location.\n\t\tstoragePath,\n\t});\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yarn-tool/fix-all",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "auto check/fix workspaces/package",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"yarn",
|
|
7
|
+
"yarn-tool",
|
|
8
|
+
"npm",
|
|
9
|
+
"lerna",
|
|
10
|
+
"workspaces",
|
|
11
|
+
"pkg",
|
|
12
|
+
"dependencies",
|
|
13
|
+
"monorepo",
|
|
14
|
+
"yarnlock",
|
|
15
|
+
"node-modules",
|
|
16
|
+
"packages",
|
|
17
|
+
"package",
|
|
18
|
+
"create-by-yarn-tool"
|
|
19
|
+
],
|
|
20
|
+
"homepage": "https://github.com/bluelovers/ws-yarn-workspaces/tree/master/packages/@yarn-tool/fix-all#readme",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/bluelovers/ws-yarn-workspaces/issues"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/bluelovers/ws-yarn-workspaces.git"
|
|
27
|
+
},
|
|
28
|
+
"license": "ISC",
|
|
29
|
+
"author": "bluelovers",
|
|
30
|
+
"main": "index.js",
|
|
31
|
+
"scripts": {
|
|
32
|
+
"coverage": "yarn run test -- --coverage",
|
|
33
|
+
"lint": "ynpx --quiet eslint -- **/*.ts",
|
|
34
|
+
"test": "jest --passWithNoTests",
|
|
35
|
+
"test:jest": "jest --passWithNoTests",
|
|
36
|
+
"test:mocha": "ynpx --quiet -p ts-node -p mocha mocha -- --require ts-node/register \"!(node_modules)/**/*.{test,spec}.{ts,tsx}\"",
|
|
37
|
+
"test:tsdx": "ynpx @bluelovers/tsdx test --passWithNoTests",
|
|
38
|
+
"build:dts": "ynpx dts-bundle-generator -o ./dist/index.d.ts ./src/index.ts --no-banner & echo build:dts",
|
|
39
|
+
"build:dts:copy": "copy .\\src\\index.d.ts .\\dist\\index.d.ts & echo build:dts",
|
|
40
|
+
"build:dts:tsc": "tsc --emitDeclarationOnly --declaration --noEmit false",
|
|
41
|
+
"build:microbundle": "ynpx microbundle --target node",
|
|
42
|
+
"build:tsdx": "ynpx @bluelovers/tsdx build --target node --name index",
|
|
43
|
+
"preversion": "echo preversion && yarn run test",
|
|
44
|
+
"version": "echo version",
|
|
45
|
+
"postversion": "echo postversion",
|
|
46
|
+
"prepublish": "echo prepublish",
|
|
47
|
+
"prepublishOnly": "echo prepublishOnly",
|
|
48
|
+
"prepublishOnly:update": "yarn run ncu && yarn run sort-package-json",
|
|
49
|
+
"publish": "echo publish",
|
|
50
|
+
"postpublish": "echo postpublish",
|
|
51
|
+
"postpublishOnly": "echo postpublishOnly",
|
|
52
|
+
"ncu": "yarn-tool ncu -u",
|
|
53
|
+
"sort-package-json": "yarn-tool sort",
|
|
54
|
+
"tsc:showConfig": "ynpx get-current-tsconfig -p"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@yarn-tool/find-root": "^1.0.59",
|
|
58
|
+
"@yarn-tool/pkg-git-info": "^1.0.24",
|
|
59
|
+
"@yarn-tool/pkg-hosted-info": "^1.0.8",
|
|
60
|
+
"@yarn-tool/ws-scope": "^1.0.11",
|
|
61
|
+
"bluebird": "^3.7.2",
|
|
62
|
+
"cache-path": "^2.0.28",
|
|
63
|
+
"debug-color2": "^1.2.7",
|
|
64
|
+
"fs-extra": "^10.0.0",
|
|
65
|
+
"lazy-aggregate-error": "^1.0.6",
|
|
66
|
+
"npm-package-json-loader": "^1.0.67",
|
|
67
|
+
"progress-estimator": "^0.3.0",
|
|
68
|
+
"sort-package-json3": "^1.0.48",
|
|
69
|
+
"ts-type": "^2.1.2",
|
|
70
|
+
"tslib": "^2.3.1",
|
|
71
|
+
"upath2": "^3.1.10",
|
|
72
|
+
"ws-pkg-list": "^1.0.71"
|
|
73
|
+
},
|
|
74
|
+
"publishConfig": {
|
|
75
|
+
"access": "public"
|
|
76
|
+
},
|
|
77
|
+
"packageManager": "yarn@^1.22.11",
|
|
78
|
+
"gitHead": "1e6163c54a28b6fcc9adba88f1b227707bc4634c"
|
|
79
|
+
}
|