keycloakify 11.4.0-rc.0 → 11.4.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/README.md +2 -0
- package/account/i18n/noJsx/getI18n.js +5 -7
- package/account/i18n/noJsx/getI18n.js.map +1 -1
- package/account/i18n/withJsx/useI18n.js +15 -4
- package/account/i18n/withJsx/useI18n.js.map +1 -1
- package/bin/20.index.js +0 -85
- package/bin/33.index.js +55 -212
- package/bin/356.index.js +106 -45
- package/bin/36.index.js +1 -2922
- package/bin/{526.index.js → 392.index.js} +89 -3
- package/bin/40.index.js +1 -86
- package/bin/453.index.js +85 -22
- package/bin/573.index.js +4 -86
- package/bin/653.index.js +752 -0
- package/bin/658.index.js +197 -0
- package/bin/735.index.js +343 -116
- package/bin/786.index.js +78 -14
- package/bin/805.index.js +15 -18
- package/bin/921.index.js +79 -18
- package/bin/97.index.js +64 -13
- package/bin/main.js +165 -86
- package/bin/shared/constants.d.ts +2 -0
- package/bin/shared/constants.js +3 -1
- package/bin/shared/constants.js.map +1 -1
- package/bin/start-keycloak/startViteDevServer.d.ts +7 -0
- package/bin/tools/crawlAsync.d.ts +1 -1
- package/bin/tools/isTrackedByGit.d.ts +3 -0
- package/bin/tools/runPrettier.d.ts +5 -5
- package/bin/tools/untrackFromGit.d.ts +3 -0
- package/lib/getKcClsx.js +1 -2
- package/lib/getKcClsx.js.map +1 -1
- package/login/KcContext/KcContext.d.ts +2 -2
- package/login/KcContext/kcContextMocks.d.ts +1 -1
- package/login/TemplateProps.d.ts +0 -1
- package/login/i18n/noJsx/getI18n.js +5 -7
- package/login/i18n/noJsx/getI18n.js.map +1 -1
- package/login/i18n/withJsx/useI18n.js +15 -4
- package/login/i18n/withJsx/useI18n.js.map +1 -1
- package/login/pages/LoginConfigTotp.js +1 -1
- package/login/pages/LoginConfigTotp.js.map +1 -1
- package/login/pages/LoginPasskeysConditionalAuthenticate.js +16 -18
- package/login/pages/LoginPasskeysConditionalAuthenticate.js.map +1 -1
- package/package.json +17 -7
- package/src/account/i18n/noJsx/getI18n.tsx +5 -7
- package/src/account/i18n/withJsx/useI18n.tsx +18 -4
- package/src/bin/eject-page.ts +28 -10
- package/src/bin/initialize-account-theme/initializeAccountTheme_singlePage.ts +3 -18
- package/src/bin/initialize-account-theme/updateAccountThemeImplementationInConfig.ts +1 -2
- package/src/bin/keycloakify/generateFtl/kcContextDeclarationTemplate.ftl +39 -0
- package/src/bin/keycloakify/generateResources/generateResources.ts +6 -2
- package/src/bin/main.ts +51 -4
- package/src/bin/postinstall/getUiModuleFileSourceCodeReadyToBeCopied.ts +30 -19
- package/src/bin/postinstall/installUiModulesPeerDependencies.ts +3 -3
- package/src/bin/postinstall/managedGitignoreFile.ts +4 -3
- package/src/bin/postinstall/postinstall.ts +24 -2
- package/src/bin/postinstall/uiModuleMeta.ts +14 -9
- package/src/bin/shared/buildContext.ts +1 -2
- package/src/bin/shared/constants.ts +4 -1
- package/src/bin/start-keycloak/myrealm-realm-25.json +21 -34
- package/src/bin/start-keycloak/myrealm-realm-26.json +32 -35
- package/src/bin/start-keycloak/start-keycloak.ts +93 -1
- package/src/bin/start-keycloak/startViteDevServer.ts +39 -0
- package/src/bin/tools/crawlAsync.ts +6 -6
- package/src/bin/tools/isTrackedByGit.ts +29 -0
- package/src/bin/tools/listInstalledModules.ts +1 -2
- package/src/bin/tools/npmInstall.ts +396 -1
- package/src/bin/tools/runPrettier.ts +63 -14
- package/src/bin/tools/untrackFromGit.ts +24 -0
- package/src/bin/tsconfig.json +1 -1
- package/src/bin/update-kc-gen.ts +17 -2
- package/src/lib/getKcClsx.ts +1 -2
- package/src/login/KcContext/KcContext.ts +2 -2
- package/src/login/KcContext/kcContextMocks.ts +1 -1
- package/src/login/TemplateProps.ts +0 -1
- package/src/login/i18n/noJsx/getI18n.tsx +5 -7
- package/src/login/i18n/withJsx/useI18n.tsx +18 -4
- package/src/login/pages/LoginConfigTotp.tsx +18 -20
- package/src/login/pages/LoginPasskeysConditionalAuthenticate.tsx +51 -52
- package/src/tools/StatefulObservable/StatefulObservable.ts +1 -2
- package/src/tools/deepAssign.ts +1 -2
- package/src/tools/extractLastParenthesisContent.ts +43 -0
- package/src/vite-plugin/vite-plugin.ts +67 -0
- package/stories/login/pages/Info.stories.tsx +3 -39
- package/tools/StatefulObservable/StatefulObservable.js +1 -2
- package/tools/StatefulObservable/StatefulObservable.js.map +1 -1
- package/tools/deepAssign.js +1 -2
- package/tools/deepAssign.js.map +1 -1
- package/tools/extractLastParenthesisContent.d.ts +6 -0
- package/tools/extractLastParenthesisContent.js +36 -0
- package/tools/extractLastParenthesisContent.js.map +1 -0
- package/vite-plugin/index.js +326 -186
- package/bin/124.index.js +0 -348
- package/stories/login/pages/LoginDeviceVerifyUserCode.stories.tsx +0 -18
package/bin/735.index.js
CHANGED
@@ -52,15 +52,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
52
52
|
/* harmony import */ var _tools_SemVer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(12171);
|
53
53
|
/* harmony import */ var make_fetch_happen__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(9525);
|
54
54
|
/* harmony import */ var make_fetch_happen__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(make_fetch_happen__WEBPACK_IMPORTED_MODULE_5__);
|
55
|
-
/* harmony import */ var
|
55
|
+
/* harmony import */ var zod__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(52300);
|
56
56
|
/* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(29041);
|
57
|
-
/* harmony import */ var
|
58
|
-
/* harmony import */ var
|
59
|
-
/* harmony import */ var
|
60
|
-
/* harmony import */ var _copyBoilerplate__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(81434);
|
61
|
-
/* harmony import */ var _tools_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(58822);
|
62
|
-
|
63
|
-
|
57
|
+
/* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(38469);
|
58
|
+
/* harmony import */ var _tools_npmInstall__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(63046);
|
59
|
+
/* harmony import */ var _copyBoilerplate__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(81434);
|
64
60
|
|
65
61
|
|
66
62
|
|
@@ -88,28 +84,28 @@ async function initializeAccountTheme_singlePage(params) {
|
|
88
84
|
.then(r => r.json())
|
89
85
|
.then((() => {
|
90
86
|
const zDependencies = (() => {
|
91
|
-
const zTargetType =
|
92
|
-
dependencies:
|
93
|
-
devDependencies:
|
87
|
+
const zTargetType = zod__WEBPACK_IMPORTED_MODULE_9__.z.object({
|
88
|
+
dependencies: zod__WEBPACK_IMPORTED_MODULE_9__.z.record(zod__WEBPACK_IMPORTED_MODULE_9__.z.string()),
|
89
|
+
devDependencies: zod__WEBPACK_IMPORTED_MODULE_9__.z.record(zod__WEBPACK_IMPORTED_MODULE_9__.z.string()).optional()
|
94
90
|
});
|
95
91
|
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__/* .assert */ .h)();
|
96
|
-
return (0,
|
92
|
+
return (0,tsafe_id__WEBPACK_IMPORTED_MODULE_10__.id)(zTargetType);
|
97
93
|
})();
|
98
94
|
return o => zDependencies.parse(o);
|
99
95
|
})());
|
100
96
|
dependencies.dependencies["@keycloakify/keycloak-account-ui"] = _tools_SemVer__WEBPACK_IMPORTED_MODULE_4__/* .SemVer.stringify */ .h.stringify(semVersionedTag.version);
|
101
97
|
const parsedPackageJson = (() => {
|
102
98
|
const zParsedPackageJson = (() => {
|
103
|
-
const zTargetType =
|
104
|
-
dependencies:
|
105
|
-
devDependencies:
|
99
|
+
const zTargetType = zod__WEBPACK_IMPORTED_MODULE_9__.z.object({
|
100
|
+
dependencies: zod__WEBPACK_IMPORTED_MODULE_9__.z.record(zod__WEBPACK_IMPORTED_MODULE_9__.z.string()).optional(),
|
101
|
+
devDependencies: zod__WEBPACK_IMPORTED_MODULE_9__.z.record(zod__WEBPACK_IMPORTED_MODULE_9__.z.string()).optional()
|
106
102
|
});
|
107
103
|
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__/* .assert */ .h)();
|
108
|
-
return (0,
|
104
|
+
return (0,tsafe_id__WEBPACK_IMPORTED_MODULE_10__.id)(zTargetType);
|
109
105
|
})();
|
110
106
|
const parsedPackageJson = JSON.parse(fs__WEBPACK_IMPORTED_MODULE_1__.readFileSync(buildContext.packageJsonFilePath).toString("utf8"));
|
111
107
|
zParsedPackageJson.parse(parsedPackageJson);
|
112
|
-
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__/* .assert */ .h)((0,
|
108
|
+
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__/* .assert */ .h)((0,tsafe_assert__WEBPACK_IMPORTED_MODULE_6__.is)(parsedPackageJson));
|
113
109
|
return parsedPackageJson;
|
114
110
|
})();
|
115
111
|
parsedPackageJson.dependencies = Object.assign(Object.assign({}, parsedPackageJson.dependencies), dependencies.dependencies);
|
@@ -118,15 +114,8 @@ async function initializeAccountTheme_singlePage(params) {
|
|
118
114
|
delete parsedPackageJson.devDependencies;
|
119
115
|
}
|
120
116
|
fs__WEBPACK_IMPORTED_MODULE_1__.writeFileSync(buildContext.packageJsonFilePath, JSON.stringify(parsedPackageJson, undefined, 4));
|
121
|
-
|
122
|
-
|
123
|
-
.toString("utf8"))["version"] === "0.0.0") {
|
124
|
-
//NOTE: Linked version
|
125
|
-
break run_npm_install;
|
126
|
-
}
|
127
|
-
(0,_tools_npmInstall__WEBPACK_IMPORTED_MODULE_8__/* .npmInstall */ .c)({ packageJsonDirPath: (0,path__WEBPACK_IMPORTED_MODULE_0__.dirname)(buildContext.packageJsonFilePath) });
|
128
|
-
}
|
129
|
-
(0,_copyBoilerplate__WEBPACK_IMPORTED_MODULE_9__/* .copyBoilerplate */ .T)({
|
117
|
+
(0,_tools_npmInstall__WEBPACK_IMPORTED_MODULE_7__/* .npmInstall */ .c)({ packageJsonDirPath: (0,path__WEBPACK_IMPORTED_MODULE_0__.dirname)(buildContext.packageJsonFilePath) });
|
118
|
+
(0,_copyBoilerplate__WEBPACK_IMPORTED_MODULE_8__/* .copyBoilerplate */ .T)({
|
130
119
|
accountThemeType: "Single-Page",
|
131
120
|
accountThemeSrcDirPath
|
132
121
|
});
|
@@ -413,105 +402,96 @@ async function getLatestsSemVersionedTag(_a) {
|
|
413
402
|
|
414
403
|
/***/ }),
|
415
404
|
|
416
|
-
/***/
|
405
|
+
/***/ 89693:
|
417
406
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
418
407
|
|
419
408
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
420
|
-
/* harmony export */ "
|
409
|
+
/* harmony export */ "a": () => (/* binding */ rmSync)
|
421
410
|
/* harmony export */ });
|
422
|
-
var
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
Object.defineProperty(semVer, "parsedFrom", {
|
439
|
-
enumerable: true,
|
440
|
-
get: function () {
|
441
|
-
const currentStr = stringify(this);
|
442
|
-
if (currentStr !== initialStr) {
|
443
|
-
throw new Error(`SemVer.parsedFrom can't be read anymore, the version have been modified from ${initialStr} to ${currentStr}`);
|
444
|
-
}
|
445
|
-
return versionStr;
|
446
|
-
}
|
447
|
-
});
|
448
|
-
return semVer;
|
411
|
+
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(57147);
|
412
|
+
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_0__);
|
413
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
|
414
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
|
415
|
+
/* harmony import */ var _SemVer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(12171);
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
/**
|
420
|
+
* Polyfill of fs.rmSync(dirPath, { "recursive": true })
|
421
|
+
* For older version of Node
|
422
|
+
*/
|
423
|
+
function rmSync(dirPath, options) {
|
424
|
+
if (_SemVer__WEBPACK_IMPORTED_MODULE_2__/* .SemVer.compare */ .h.compare(_SemVer__WEBPACK_IMPORTED_MODULE_2__/* .SemVer.parse */ .h.parse(process.version), _SemVer__WEBPACK_IMPORTED_MODULE_2__/* .SemVer.parse */ .h.parse("14.14.0")) > 0) {
|
425
|
+
fs__WEBPACK_IMPORTED_MODULE_0__.rmSync(dirPath, options);
|
426
|
+
return;
|
449
427
|
}
|
450
|
-
|
451
|
-
|
452
|
-
return
|
428
|
+
const { force = true } = options;
|
429
|
+
if (force && !fs__WEBPACK_IMPORTED_MODULE_0__.existsSync(dirPath)) {
|
430
|
+
return;
|
453
431
|
}
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
* v1 > v2 => 1
|
460
|
-
*
|
461
|
-
*/
|
462
|
-
function compare(v1, v2) {
|
463
|
-
const sign = (diff) => (diff === 0 ? 0 : diff < 0 ? -1 : 1);
|
464
|
-
const noUndefined = (n) => n !== null && n !== void 0 ? n : Infinity;
|
465
|
-
for (const level of ["major", "minor", "patch", "rc"]) {
|
466
|
-
if (noUndefined(v1[level]) !== noUndefined(v2[level])) {
|
467
|
-
return sign(noUndefined(v1[level]) - noUndefined(v2[level]));
|
468
|
-
}
|
432
|
+
const removeDir_rec = (dirPath) => fs__WEBPACK_IMPORTED_MODULE_0__.readdirSync(dirPath).forEach(basename => {
|
433
|
+
const fileOrDirPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(dirPath, basename);
|
434
|
+
if (fs__WEBPACK_IMPORTED_MODULE_0__.lstatSync(fileOrDirPath).isDirectory()) {
|
435
|
+
removeDir_rec(fileOrDirPath);
|
436
|
+
return;
|
469
437
|
}
|
470
|
-
|
471
|
-
|
472
|
-
SemVer.compare = compare;
|
473
|
-
/*
|
474
|
-
console.log(compare(parse("3.0.0-rc.3"), parse("3.0.0")) === -1 )
|
475
|
-
console.log(compare(parse("3.0.0-rc.3"), parse("3.0.0-rc.4")) === -1 )
|
476
|
-
console.log(compare(parse("3.0.0-rc.3"), parse("4.0.0")) === -1 )
|
477
|
-
*/
|
478
|
-
function bumpType(params) {
|
479
|
-
const versionAhead = typeof params.versionAhead === "string"
|
480
|
-
? parse(params.versionAhead)
|
481
|
-
: params.versionAhead;
|
482
|
-
const versionBehind = typeof params.versionBehind === "string"
|
483
|
-
? parse(params.versionBehind)
|
484
|
-
: params.versionBehind;
|
485
|
-
if (compare(versionBehind, versionAhead) === 1) {
|
486
|
-
throw new Error(`Version regression ${stringify(versionBehind)} -> ${stringify(versionAhead)}`);
|
487
|
-
}
|
488
|
-
for (const level of ["major", "minor", "patch", "rc"]) {
|
489
|
-
if (versionBehind[level] !== versionAhead[level]) {
|
490
|
-
return level;
|
491
|
-
}
|
438
|
+
else {
|
439
|
+
fs__WEBPACK_IMPORTED_MODULE_0__.unlinkSync(fileOrDirPath);
|
492
440
|
}
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
//# sourceMappingURL=SemVer.js.map
|
441
|
+
});
|
442
|
+
removeDir_rec(dirPath);
|
443
|
+
}
|
444
|
+
//# sourceMappingURL=fs.rmSync.js.map
|
498
445
|
|
499
446
|
/***/ }),
|
500
447
|
|
501
|
-
/***/
|
448
|
+
/***/ 63046:
|
502
449
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
503
450
|
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
451
|
+
|
452
|
+
// EXPORTS
|
453
|
+
__webpack_require__.d(__webpack_exports__, {
|
454
|
+
"c": () => (/* binding */ npmInstall)
|
455
|
+
});
|
456
|
+
|
457
|
+
// EXTERNAL MODULE: external "fs"
|
458
|
+
var external_fs_ = __webpack_require__(57147);
|
459
|
+
// EXTERNAL MODULE: external "path"
|
460
|
+
var external_path_ = __webpack_require__(71017);
|
461
|
+
// EXTERNAL MODULE: external "child_process"
|
462
|
+
var external_child_process_ = __webpack_require__(32081);
|
463
|
+
// EXTERNAL MODULE: ./node_modules/chalk/source/index.js
|
464
|
+
var source = __webpack_require__(78818);
|
465
|
+
var source_default = /*#__PURE__*/__webpack_require__.n(source);
|
466
|
+
// EXTERNAL MODULE: ./node_modules/zod/lib/index.mjs
|
467
|
+
var lib = __webpack_require__(52300);
|
468
|
+
// EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
|
469
|
+
var assert = __webpack_require__(29041);
|
470
|
+
// EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
|
471
|
+
var id = __webpack_require__(38469);
|
472
|
+
;// CONCATENATED MODULE: ./node_modules/tsafe/esm/objectKeys.mjs
|
473
|
+
/** https://docs.tsafe.dev/objectKeys */
|
474
|
+
function objectKeys(o) {
|
475
|
+
return Object.keys(o);
|
476
|
+
}
|
477
|
+
|
478
|
+
|
479
|
+
//# sourceMappingURL=objectKeys.mjs.map
|
480
|
+
|
481
|
+
// EXTERNAL MODULE: ./dist/bin/tools/getAbsoluteAndInOsFormatPath.js
|
482
|
+
var getAbsoluteAndInOsFormatPath = __webpack_require__(84794);
|
483
|
+
// EXTERNAL MODULE: ./node_modules/tsafe/esm/exclude.mjs
|
484
|
+
var exclude = __webpack_require__(83101);
|
485
|
+
// EXTERNAL MODULE: ./dist/bin/tools/fs.rmSync.js
|
486
|
+
var fs_rmSync = __webpack_require__(89693);
|
487
|
+
;// CONCATENATED MODULE: ./dist/bin/tools/npmInstall.js
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
|
494
|
+
|
515
495
|
|
516
496
|
|
517
497
|
|
@@ -542,22 +522,269 @@ function npmInstall(params) {
|
|
542
522
|
}
|
543
523
|
];
|
544
524
|
for (const packageManager of packageMangers) {
|
545
|
-
if (
|
546
|
-
|
525
|
+
if (external_fs_.existsSync((0,external_path_.join)(packageJsonDirPath, packageManager.lockFileBasename)) ||
|
526
|
+
external_fs_.existsSync((0,external_path_.join)(process.cwd(), packageManager.lockFileBasename))) {
|
547
527
|
return packageManager.binName;
|
548
528
|
}
|
549
529
|
}
|
550
530
|
throw new Error("No lock file found, cannot tell which package manager to use for installing dependencies.");
|
551
531
|
})();
|
552
532
|
console.log(`Installing the new dependencies...`);
|
533
|
+
install_without_breaking_links: {
|
534
|
+
if (packageManagerBinName !== "yarn") {
|
535
|
+
break install_without_breaking_links;
|
536
|
+
}
|
537
|
+
const garronejLinkInfos = getGarronejLinkInfos({ packageJsonDirPath });
|
538
|
+
if (garronejLinkInfos === undefined) {
|
539
|
+
break install_without_breaking_links;
|
540
|
+
}
|
541
|
+
console.log(source_default().green("Installing in a way that won't break the links..."));
|
542
|
+
installWithoutBreakingLinks({
|
543
|
+
packageJsonDirPath,
|
544
|
+
garronejLinkInfos
|
545
|
+
});
|
546
|
+
return;
|
547
|
+
}
|
553
548
|
try {
|
554
|
-
|
549
|
+
external_child_process_.execSync(`${packageManagerBinName} install`, {
|
555
550
|
cwd: packageJsonDirPath,
|
556
551
|
stdio: "inherit"
|
557
552
|
});
|
558
553
|
}
|
559
554
|
catch (_a) {
|
560
|
-
console.log(
|
555
|
+
console.log(source_default().yellow(`\`${packageManagerBinName} install\` failed, continuing anyway...`));
|
556
|
+
}
|
557
|
+
}
|
558
|
+
function getGarronejLinkInfos(params) {
|
559
|
+
const { packageJsonDirPath } = params;
|
560
|
+
const nodeModuleDirPath = (0,external_path_.join)(packageJsonDirPath, "node_modules");
|
561
|
+
if (!external_fs_.existsSync(nodeModuleDirPath)) {
|
562
|
+
return undefined;
|
563
|
+
}
|
564
|
+
const linkedModuleNames = [];
|
565
|
+
let yarnHomeDirPath = undefined;
|
566
|
+
const getIsLinkedByGarronejScript = (path) => {
|
567
|
+
let realPath;
|
568
|
+
try {
|
569
|
+
realPath = external_fs_.readlinkSync(path);
|
570
|
+
}
|
571
|
+
catch (_a) {
|
572
|
+
return false;
|
573
|
+
}
|
574
|
+
const doesIncludeYarnHome = realPath.includes(".yarn_home");
|
575
|
+
if (!doesIncludeYarnHome) {
|
576
|
+
return false;
|
577
|
+
}
|
578
|
+
set_yarnHomeDirPath: {
|
579
|
+
if (yarnHomeDirPath !== undefined) {
|
580
|
+
break set_yarnHomeDirPath;
|
581
|
+
}
|
582
|
+
const [firstElement] = (0,getAbsoluteAndInOsFormatPath/* getAbsoluteAndInOsFormatPath */.c)({
|
583
|
+
pathIsh: realPath,
|
584
|
+
cwd: (0,external_path_.dirname)(path)
|
585
|
+
}).split(".yarn_home");
|
586
|
+
yarnHomeDirPath = (0,external_path_.join)(firstElement, ".yarn_home");
|
587
|
+
}
|
588
|
+
return true;
|
589
|
+
};
|
590
|
+
for (const basename of external_fs_.readdirSync(nodeModuleDirPath)) {
|
591
|
+
const path = (0,external_path_.join)(nodeModuleDirPath, basename);
|
592
|
+
if (external_fs_.lstatSync(path).isSymbolicLink()) {
|
593
|
+
if (basename.startsWith("@")) {
|
594
|
+
return undefined;
|
595
|
+
}
|
596
|
+
if (!getIsLinkedByGarronejScript(path)) {
|
597
|
+
return undefined;
|
598
|
+
}
|
599
|
+
linkedModuleNames.push(basename);
|
600
|
+
continue;
|
601
|
+
}
|
602
|
+
if (!external_fs_.lstatSync(path).isDirectory()) {
|
603
|
+
continue;
|
604
|
+
}
|
605
|
+
if (basename.startsWith("@")) {
|
606
|
+
for (const subBasename of external_fs_.readdirSync(path)) {
|
607
|
+
const subPath = (0,external_path_.join)(path, subBasename);
|
608
|
+
if (!external_fs_.lstatSync(subPath).isSymbolicLink()) {
|
609
|
+
continue;
|
610
|
+
}
|
611
|
+
if (!getIsLinkedByGarronejScript(subPath)) {
|
612
|
+
return undefined;
|
613
|
+
}
|
614
|
+
linkedModuleNames.push(`${basename}/${subBasename}`);
|
615
|
+
}
|
616
|
+
}
|
617
|
+
}
|
618
|
+
if (yarnHomeDirPath === undefined) {
|
619
|
+
return undefined;
|
620
|
+
}
|
621
|
+
return { linkedModuleNames, yarnHomeDirPath };
|
622
|
+
}
|
623
|
+
function installWithoutBreakingLinks(params) {
|
624
|
+
const { packageJsonDirPath, garronejLinkInfos: { linkedModuleNames, yarnHomeDirPath } } = params;
|
625
|
+
const parsedPackageJson = (() => {
|
626
|
+
const packageJsonFilePath = (0,external_path_.join)(packageJsonDirPath, "package.json");
|
627
|
+
const zParsedPackageJson = (() => {
|
628
|
+
const zTargetType = lib.z.object({
|
629
|
+
scripts: lib.z.record(lib.z.string()).optional()
|
630
|
+
});
|
631
|
+
assert/* assert */.h;
|
632
|
+
return (0,id.id)(zTargetType);
|
633
|
+
})();
|
634
|
+
const parsedPackageJson = JSON.parse(external_fs_.readFileSync(packageJsonFilePath).toString("utf8"));
|
635
|
+
zParsedPackageJson.parse(parsedPackageJson);
|
636
|
+
(0,assert/* assert */.h)((0,assert.is)(parsedPackageJson));
|
637
|
+
return parsedPackageJson;
|
638
|
+
})();
|
639
|
+
const isImplementedScriptByName = {
|
640
|
+
postinstall: false,
|
641
|
+
prepare: false
|
642
|
+
};
|
643
|
+
delete_postinstall_script: {
|
644
|
+
if (parsedPackageJson.scripts === undefined) {
|
645
|
+
break delete_postinstall_script;
|
646
|
+
}
|
647
|
+
for (const scriptName of objectKeys(isImplementedScriptByName)) {
|
648
|
+
if (parsedPackageJson.scripts[scriptName] === undefined) {
|
649
|
+
continue;
|
650
|
+
}
|
651
|
+
isImplementedScriptByName[scriptName] = true;
|
652
|
+
delete parsedPackageJson.scripts[scriptName];
|
653
|
+
}
|
654
|
+
}
|
655
|
+
const tmpProjectDirPath = (0,external_path_.join)(yarnHomeDirPath, "tmpProject");
|
656
|
+
if (external_fs_.existsSync(tmpProjectDirPath)) {
|
657
|
+
(0,fs_rmSync/* rmSync */.a)(tmpProjectDirPath, { recursive: true });
|
658
|
+
}
|
659
|
+
external_fs_.mkdirSync(tmpProjectDirPath, { recursive: true });
|
660
|
+
external_fs_.writeFileSync((0,external_path_.join)(tmpProjectDirPath, "package.json"), JSON.stringify(parsedPackageJson, undefined, 4));
|
661
|
+
const YARN_LOCK = "yarn.lock";
|
662
|
+
external_fs_.copyFileSync((0,external_path_.join)(packageJsonDirPath, YARN_LOCK), (0,external_path_.join)(tmpProjectDirPath, YARN_LOCK));
|
663
|
+
external_child_process_.execSync(`yarn install`, {
|
664
|
+
cwd: tmpProjectDirPath,
|
665
|
+
stdio: "inherit"
|
666
|
+
});
|
667
|
+
// NOTE: Moving the modules from the tmp project to the actual project
|
668
|
+
// without messing up the links.
|
669
|
+
{
|
670
|
+
const { getAreSameVersions } = (() => {
|
671
|
+
const zParsedPackageJson = (() => {
|
672
|
+
const zTargetType = lib.z.object({
|
673
|
+
version: lib.z.string()
|
674
|
+
});
|
675
|
+
assert/* assert */.h;
|
676
|
+
return (0,id.id)(zTargetType);
|
677
|
+
})();
|
678
|
+
function readVersion(params) {
|
679
|
+
const { moduleDirPath } = params;
|
680
|
+
const packageJsonFilePath = (0,external_path_.join)(moduleDirPath, "package.json");
|
681
|
+
const packageJson = JSON.parse(external_fs_.readFileSync(packageJsonFilePath).toString("utf8"));
|
682
|
+
zParsedPackageJson.parse(packageJson);
|
683
|
+
(0,assert/* assert */.h)((0,assert.is)(packageJson));
|
684
|
+
return packageJson.version;
|
685
|
+
}
|
686
|
+
function getAreSameVersions(params) {
|
687
|
+
const { moduleDirPath_a, moduleDirPath_b } = params;
|
688
|
+
return (readVersion({ moduleDirPath: moduleDirPath_a }) ===
|
689
|
+
readVersion({ moduleDirPath: moduleDirPath_b }));
|
690
|
+
}
|
691
|
+
return { getAreSameVersions };
|
692
|
+
})();
|
693
|
+
const nodeModulesDirPath_tmpProject = (0,external_path_.join)(tmpProjectDirPath, "node_modules");
|
694
|
+
const nodeModulesDirPath = (0,external_path_.join)(packageJsonDirPath, "node_modules");
|
695
|
+
const modulePaths = external_fs_.readdirSync(nodeModulesDirPath_tmpProject)
|
696
|
+
.map(basename => {
|
697
|
+
if (basename.startsWith(".")) {
|
698
|
+
return undefined;
|
699
|
+
}
|
700
|
+
const path = (0,external_path_.join)(nodeModulesDirPath_tmpProject, basename);
|
701
|
+
if (basename.startsWith("@")) {
|
702
|
+
return external_fs_.readdirSync(path)
|
703
|
+
.map(subBasename => {
|
704
|
+
if (subBasename.startsWith(".")) {
|
705
|
+
return undefined;
|
706
|
+
}
|
707
|
+
const subPath = (0,external_path_.join)(path, subBasename);
|
708
|
+
if (!external_fs_.lstatSync(subPath).isDirectory()) {
|
709
|
+
return undefined;
|
710
|
+
}
|
711
|
+
return {
|
712
|
+
moduleName: `${basename}/${subBasename}`,
|
713
|
+
moduleDirPath_tmpProject: subPath,
|
714
|
+
moduleDirPath: (0,external_path_.join)(nodeModulesDirPath, basename, subBasename)
|
715
|
+
};
|
716
|
+
})
|
717
|
+
.filter((0,exclude/* exclude */.D)(undefined));
|
718
|
+
}
|
719
|
+
if (!external_fs_.lstatSync(path).isDirectory()) {
|
720
|
+
return undefined;
|
721
|
+
}
|
722
|
+
return [
|
723
|
+
{
|
724
|
+
moduleName: basename,
|
725
|
+
moduleDirPath_tmpProject: path,
|
726
|
+
moduleDirPath: (0,external_path_.join)(nodeModulesDirPath, basename)
|
727
|
+
}
|
728
|
+
];
|
729
|
+
})
|
730
|
+
.filter((0,exclude/* exclude */.D)(undefined))
|
731
|
+
.flat();
|
732
|
+
for (const { moduleName, moduleDirPath, moduleDirPath_tmpProject } of modulePaths) {
|
733
|
+
if (linkedModuleNames.includes(moduleName)) {
|
734
|
+
continue;
|
735
|
+
}
|
736
|
+
let doesTargetModuleExist = false;
|
737
|
+
skip_condition: {
|
738
|
+
if (!external_fs_.existsSync(moduleDirPath)) {
|
739
|
+
break skip_condition;
|
740
|
+
}
|
741
|
+
doesTargetModuleExist = true;
|
742
|
+
const areSameVersions = getAreSameVersions({
|
743
|
+
moduleDirPath_a: moduleDirPath,
|
744
|
+
moduleDirPath_b: moduleDirPath_tmpProject
|
745
|
+
});
|
746
|
+
if (!areSameVersions) {
|
747
|
+
break skip_condition;
|
748
|
+
}
|
749
|
+
continue;
|
750
|
+
}
|
751
|
+
if (doesTargetModuleExist) {
|
752
|
+
(0,fs_rmSync/* rmSync */.a)(moduleDirPath, { recursive: true });
|
753
|
+
}
|
754
|
+
{
|
755
|
+
const dirPath = (0,external_path_.dirname)(moduleDirPath);
|
756
|
+
if (!external_fs_.existsSync(dirPath)) {
|
757
|
+
external_fs_.mkdirSync(dirPath, { recursive: true });
|
758
|
+
}
|
759
|
+
}
|
760
|
+
external_fs_.renameSync(moduleDirPath_tmpProject, moduleDirPath);
|
761
|
+
}
|
762
|
+
move_bin: {
|
763
|
+
const binDirPath_tmpProject = (0,external_path_.join)(nodeModulesDirPath_tmpProject, ".bin");
|
764
|
+
const binDirPath = (0,external_path_.join)(nodeModulesDirPath, ".bin");
|
765
|
+
if (!external_fs_.existsSync(binDirPath_tmpProject)) {
|
766
|
+
break move_bin;
|
767
|
+
}
|
768
|
+
for (const basename of external_fs_.readdirSync(binDirPath_tmpProject)) {
|
769
|
+
const path_tmpProject = (0,external_path_.join)(binDirPath_tmpProject, basename);
|
770
|
+
const path = (0,external_path_.join)(binDirPath, basename);
|
771
|
+
if (external_fs_.existsSync(path)) {
|
772
|
+
continue;
|
773
|
+
}
|
774
|
+
external_fs_.renameSync(path_tmpProject, path);
|
775
|
+
}
|
776
|
+
}
|
777
|
+
}
|
778
|
+
external_fs_.cpSync((0,external_path_.join)(tmpProjectDirPath, YARN_LOCK), (0,external_path_.join)(packageJsonDirPath, YARN_LOCK));
|
779
|
+
(0,fs_rmSync/* rmSync */.a)(tmpProjectDirPath, { recursive: true });
|
780
|
+
for (const scriptName of objectKeys(isImplementedScriptByName)) {
|
781
|
+
if (!isImplementedScriptByName[scriptName]) {
|
782
|
+
continue;
|
783
|
+
}
|
784
|
+
external_child_process_.execSync(`yarn run ${scriptName}`, {
|
785
|
+
cwd: packageJsonDirPath,
|
786
|
+
stdio: "inherit"
|
787
|
+
});
|
561
788
|
}
|
562
789
|
}
|
563
790
|
//# sourceMappingURL=npmInstall.js.map
|