keycloakify 11.8.45 → 11.8.47-rc.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/bin/254.index.js +283 -0
- package/bin/30.index.js +25 -0
- package/bin/{864.index.js → 309.index.js} +6944 -28439
- package/bin/311.index.js +198 -0
- package/bin/{313.index.js → 355.index.js} +101 -147
- package/bin/{84.index.js → 502.index.js} +147 -101
- package/bin/626.index.js +194 -0
- package/bin/{698.index.js → 656.index.js} +101 -147
- package/bin/675.index.js +177 -0
- package/bin/69.index.js +1 -1
- package/bin/762.index.js +1475 -0
- package/bin/780.index.js +4 -2
- package/bin/786.index.js +115 -0
- package/bin/895.index.js +21501 -0
- package/bin/{618.index.js → 932.index.js} +117 -163
- package/bin/949.index.js +1 -1
- package/bin/97.index.js +537 -4
- package/bin/init/index.d.ts +1 -0
- package/bin/init/init.d.ts +3 -0
- package/bin/init/setupEslint.d.ts +4 -0
- package/bin/init/setupVitePluginIfNeeded.d.ts +4 -0
- package/bin/initialize-login-theme.d.ts +4 -0
- package/bin/main.js +19 -30
- package/bin/shared/customHandler.d.ts +1 -1
- package/bin/shared/customHandler.js.map +1 -1
- package/package.json +82 -66
- package/src/bin/init/index.ts +1 -0
- package/src/bin/init/init.ts +354 -0
- package/src/bin/init/setupEslint.ts +80 -0
- package/src/bin/init/setupVitePluginIfNeeded.ts +143 -0
- package/src/bin/initialize-account-theme/initialize-account-theme.ts +4 -0
- package/src/bin/initialize-login-theme.ts +323 -0
- package/src/bin/main.ts +14 -0
- package/src/bin/shared/buildContext.ts +2 -37
- package/src/bin/shared/customHandler.ts +3 -1
- package/src/bin/sync-extensions/extensionModuleMeta.ts +89 -73
- package/src/bin/sync-extensions/managedGitignoreFiles.ts +32 -2
- package/vite-plugin/index.js +1 -24
- package/bin/433.index.js +0 -140
- /package/res/public/keycloakify-dev-resources/account/{account/css → css}/account.css +0 -0
- /package/res/public/keycloakify-dev-resources/account/{account/img → img}/icon-sidebar-active.png +0 -0
- /package/res/public/keycloakify-dev-resources/account/{account/img → img}/keycloak-logo.png +0 -0
- /package/res/public/keycloakify-dev-resources/account/{account/img → img}/logo.png +0 -0
- /package/res/public/keycloakify-dev-resources/account/{account/resources-common → resources-common}/img/favicon.ico +0 -0
- /package/res/public/keycloakify-dev-resources/account/{account/resources-common → resources-common}/node_modules/patternfly/dist/css/patternfly-additions.min.css +0 -0
- /package/res/public/keycloakify-dev-resources/account/{account/resources-common → resources-common}/node_modules/patternfly/dist/css/patternfly.min.css +0 -0
- /package/res/public/keycloakify-dev-resources/account/{account/resources-common → resources-common}/node_modules/patternfly/dist/fonts/OpenSans-Bold-webfont.woff2 +0 -0
- /package/res/public/keycloakify-dev-resources/account/{account/resources-common → resources-common}/node_modules/patternfly/dist/fonts/OpenSans-Light-webfont.woff2 +0 -0
- /package/res/public/keycloakify-dev-resources/account/{account/resources-common → resources-common}/node_modules/patternfly/dist/fonts/OpenSans-Regular-webfont.woff2 +0 -0
- /package/res/public/keycloakify-dev-resources/account/{account/resources-common → resources-common}/node_modules/patternfly/dist/fonts/OpenSans-Semibold-webfont.woff2 +0 -0
- /package/res/public/keycloakify-dev-resources/account/{account/resources-common → resources-common}/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.ttf +0 -0
- /package/res/public/keycloakify-dev-resources/account/{account/resources-common → resources-common}/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.woff +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/css → css}/login.css +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/img → img}/feedback-error-arrow-down.png +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/img → img}/feedback-error-sign.png +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/img → img}/feedback-success-arrow-down.png +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/img → img}/feedback-success-sign.png +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/img → img}/feedback-warning-arrow-down.png +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/img → img}/feedback-warning-sign.png +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/img → img}/keycloak-bg.png +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/img → img}/keycloak-logo-text.png +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/img → img}/keycloak-logo.png +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/js → js}/authChecker.js +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/js → js}/common.js +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/js → js}/kcMultivalued.js +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/js → js}/kcNumberFormat.js +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/js → js}/kcNumberUnFormat.js +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/js → js}/menu-button-links.js +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/js → js}/passkeysConditionalAuth.js +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/js → js}/passwordVisibility.js +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/js → js}/userProfile.js +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/js → js}/webauthnAuthenticate.js +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/js → js}/webauthnRegister.js +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/img/favicon.ico +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/lib/pficon/pficon.css +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/lib/pficon/pficon.woff2 +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/@patternfly/patternfly/assets/fonts/RedHatDisplay/RedHatDisplay-Bold.woff +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/@patternfly/patternfly/assets/fonts/RedHatDisplay/RedHatDisplay-Bold.woff2 +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/@patternfly/patternfly/assets/fonts/overpass-webfont/overpass-bold.woff +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/@patternfly/patternfly/assets/fonts/overpass-webfont/overpass-bold.woff2 +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/@patternfly/patternfly/patternfly.min.css +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/jquery/dist/jquery.min.js +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/patternfly/dist/css/patternfly-additions.min.css +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/patternfly/dist/css/patternfly.min.css +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/patternfly/dist/fonts/OpenSans-Bold-webfont.ttf +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/patternfly/dist/fonts/OpenSans-Bold-webfont.woff +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/patternfly/dist/fonts/OpenSans-Bold-webfont.woff2 +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/patternfly/dist/fonts/OpenSans-Light-webfont.woff2 +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/patternfly/dist/fonts/OpenSans-Regular-webfont.woff2 +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/patternfly/dist/fonts/OpenSans-Semibold-webfont.woff2 +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/patternfly/dist/fonts/OpenSans-SemiboldItalic-webfont.ttf +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/patternfly/dist/fonts/OpenSans-SemiboldItalic-webfont.woff +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/patternfly/dist/fonts/OpenSans-SemiboldItalic-webfont.woff2 +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.ttf +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/patternfly/dist/fonts/PatternFlyIcons-webfont.woff +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/patternfly/dist/fonts/fontawesome-webfont.woff2 +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/patternfly/dist/img/bg-login.jpg +0 -0
- /package/res/public/keycloakify-dev-resources/login/{login/resources-common → resources-common}/node_modules/rfc4648/lib/rfc4648.js +0 -0
package/bin/762.index.js
ADDED
@@ -0,0 +1,1475 @@
|
|
1
|
+
"use strict";
|
2
|
+
exports.id = 762;
|
3
|
+
exports.ids = [762];
|
4
|
+
exports.modules = {
|
5
|
+
|
6
|
+
/***/ 70762:
|
7
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
8
|
+
|
9
|
+
// ESM COMPAT FLAG
|
10
|
+
__webpack_require__.r(__webpack_exports__);
|
11
|
+
|
12
|
+
// EXPORTS
|
13
|
+
__webpack_require__.d(__webpack_exports__, {
|
14
|
+
"command": () => (/* reexport */ command)
|
15
|
+
});
|
16
|
+
|
17
|
+
// EXTERNAL MODULE: external "path"
|
18
|
+
var external_path_ = __webpack_require__(71017);
|
19
|
+
// EXTERNAL MODULE: ./dist/bin/tools/fs.existsAsync.js
|
20
|
+
var fs_existsAsync = __webpack_require__(43765);
|
21
|
+
// EXTERNAL MODULE: external "fs/promises"
|
22
|
+
var promises_ = __webpack_require__(73292);
|
23
|
+
// EXTERNAL MODULE: ./node_modules/recast/main.js
|
24
|
+
var main = __webpack_require__(48128);
|
25
|
+
// EXTERNAL MODULE: ./dist/bin/tools/runPrettier.js
|
26
|
+
var runPrettier = __webpack_require__(48433);
|
27
|
+
// EXTERNAL MODULE: ./node_modules/@babel/parser/lib/index.js
|
28
|
+
var lib = __webpack_require__(85026);
|
29
|
+
// EXTERNAL MODULE: ./node_modules/@babel/generator/lib/index.js
|
30
|
+
var generator_lib = __webpack_require__(92332);
|
31
|
+
// EXTERNAL MODULE: ./node_modules/@babel/types/lib/index.js
|
32
|
+
var types_lib = __webpack_require__(7912);
|
33
|
+
;// CONCATENATED MODULE: ./dist/bin/init/setupVitePluginIfNeeded.js
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
/** Best effort to setup the Keycloakify vite plugin automatically */
|
43
|
+
async function setupVitePluginIfNeeded(params) {
|
44
|
+
const { projectDirPath } = params;
|
45
|
+
const viteConfigTsFilePath = (0,external_path_.join)(projectDirPath, "vite.config.ts");
|
46
|
+
if (!(await (0,fs_existsAsync/* existsAsync */.o)(viteConfigTsFilePath))) {
|
47
|
+
return;
|
48
|
+
}
|
49
|
+
const viteConfigTsContent = (await promises_.readFile(viteConfigTsFilePath)).toString("utf8");
|
50
|
+
if (viteConfigTsContent.includes("keycloakify")) {
|
51
|
+
return;
|
52
|
+
}
|
53
|
+
const root = main/* parse */.Qc(viteConfigTsContent, {
|
54
|
+
parser: {
|
55
|
+
parse: (code) => lib/* parse */.Qc(code, {
|
56
|
+
sourceType: "module",
|
57
|
+
plugins: ["typescript"]
|
58
|
+
}),
|
59
|
+
generator: generator_lib/* default */.ZP,
|
60
|
+
types: types_lib
|
61
|
+
}
|
62
|
+
});
|
63
|
+
/* Before:
|
64
|
+
import { defineConfig } from "vite";
|
65
|
+
import react from "@vitejs/plugin-react";
|
66
|
+
|
67
|
+
// https://vitejs.dev/config/
|
68
|
+
export default defineConfig({
|
69
|
+
plugins: [ react() ]
|
70
|
+
});
|
71
|
+
*/
|
72
|
+
/* After:
|
73
|
+
import { defineConfig } from "vite";
|
74
|
+
import react from "@vitejs/plugin-react";
|
75
|
+
import { keycloakify } from "keycloakify/vite-plugin";
|
76
|
+
|
77
|
+
// https://vitejs.dev/config/
|
78
|
+
export default defineConfig({
|
79
|
+
plugins: [
|
80
|
+
react(),
|
81
|
+
keycloakify({
|
82
|
+
accountThemeImplementation: "none"
|
83
|
+
})
|
84
|
+
]
|
85
|
+
});
|
86
|
+
*/
|
87
|
+
main/* visit */.Vn(root, {
|
88
|
+
visitProgram(path) {
|
89
|
+
const body = path.node.body;
|
90
|
+
// Add import: import { keycloakify } from "keycloakify/vite-plugin";
|
91
|
+
const importDeclaration = types_lib.importDeclaration([
|
92
|
+
types_lib.importSpecifier(types_lib.identifier("keycloakify"), types_lib.identifier("keycloakify"))
|
93
|
+
], types_lib.stringLiteral("keycloakify/vite-plugin"));
|
94
|
+
// @ts-expect-error
|
95
|
+
body.unshift(importDeclaration);
|
96
|
+
this.traverse(path);
|
97
|
+
},
|
98
|
+
visitCallExpression(path) {
|
99
|
+
const { node } = path;
|
100
|
+
if (
|
101
|
+
// @ts-expect-error
|
102
|
+
types_lib.isIdentifier(node.callee, { name: "defineConfig" }) &&
|
103
|
+
node.arguments.length === 1 &&
|
104
|
+
// @ts-expect-error
|
105
|
+
types_lib.isObjectExpression(node.arguments[0])) {
|
106
|
+
const configObject = node.arguments[0];
|
107
|
+
const pluginsProp = configObject.properties.find(prop =>
|
108
|
+
// @ts-expect-error
|
109
|
+
types_lib.isObjectProperty(prop) &&
|
110
|
+
types_lib.isIdentifier(prop.key, { name: "plugins" }) &&
|
111
|
+
types_lib.isArrayExpression(prop.value));
|
112
|
+
if (pluginsProp && types_lib.isArrayExpression(pluginsProp.value)) {
|
113
|
+
// Append keycloakify plugin config
|
114
|
+
const keycloakifyCall = types_lib.callExpression(types_lib.identifier("keycloakify"), [
|
115
|
+
types_lib.objectExpression([
|
116
|
+
types_lib.objectProperty(types_lib.identifier("accountThemeImplementation"), types_lib.stringLiteral("none"))
|
117
|
+
])
|
118
|
+
]);
|
119
|
+
pluginsProp.value.elements.push(keycloakifyCall);
|
120
|
+
}
|
121
|
+
}
|
122
|
+
this.traverse(path);
|
123
|
+
}
|
124
|
+
});
|
125
|
+
let viteConfigTsContent_modified = (0,generator_lib/* default */.ZP)(root).code;
|
126
|
+
format: {
|
127
|
+
if (!(await (0,runPrettier/* getIsPrettierAvailable */.MT)())) {
|
128
|
+
break format;
|
129
|
+
}
|
130
|
+
viteConfigTsContent_modified = await (0,runPrettier/* runPrettier */.eY)({
|
131
|
+
sourceCode: viteConfigTsContent_modified,
|
132
|
+
filePath: viteConfigTsFilePath
|
133
|
+
});
|
134
|
+
}
|
135
|
+
await promises_.writeFile(viteConfigTsFilePath, Buffer.from(viteConfigTsContent_modified, "utf8"));
|
136
|
+
}
|
137
|
+
//# sourceMappingURL=setupVitePluginIfNeeded.js.map
|
138
|
+
;// CONCATENATED MODULE: ./dist/bin/init/setupEslint.js
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
/** This function will just set reportUnusedDisableDirectives to off so that we don't get warning on generated files */
|
148
|
+
async function setupEslint(params) {
|
149
|
+
const { projectDirPath } = params;
|
150
|
+
const eslintConfigJsFilePath = (0,external_path_.join)(projectDirPath, "eslint.config.js");
|
151
|
+
if (!(await (0,fs_existsAsync/* existsAsync */.o)(eslintConfigJsFilePath))) {
|
152
|
+
return;
|
153
|
+
}
|
154
|
+
const eslintConfigJsContent = (await promises_.readFile(eslintConfigJsFilePath)).toString("utf8");
|
155
|
+
if (eslintConfigJsContent.includes("reportUnusedDisableDirectives")) {
|
156
|
+
return;
|
157
|
+
}
|
158
|
+
const root = main/* parse */.Qc(eslintConfigJsContent, {
|
159
|
+
parser: {
|
160
|
+
parse: (code) => lib/* parse */.Qc(code, {
|
161
|
+
sourceType: "module",
|
162
|
+
plugins: ["typescript"]
|
163
|
+
})
|
164
|
+
}
|
165
|
+
});
|
166
|
+
main/* visit */.Vn(root, {
|
167
|
+
visitExportDefaultDeclaration(path) {
|
168
|
+
// @ts-expect-error
|
169
|
+
const args = path.node.declaration.arguments;
|
170
|
+
if (!Array.isArray(args))
|
171
|
+
return false;
|
172
|
+
args.push(types_lib.objectExpression([
|
173
|
+
types_lib.objectProperty(types_lib.identifier("linterOptions"), types_lib.objectExpression([
|
174
|
+
types_lib.objectProperty(types_lib.identifier("reportUnusedDisableDirectives"), types_lib.stringLiteral("off"))
|
175
|
+
]))
|
176
|
+
]));
|
177
|
+
return false;
|
178
|
+
}
|
179
|
+
});
|
180
|
+
let eslintConfigJsContent_modified = (0,generator_lib/* default */.ZP)(root).code;
|
181
|
+
format: {
|
182
|
+
if (!(await (0,runPrettier/* getIsPrettierAvailable */.MT)())) {
|
183
|
+
break format;
|
184
|
+
}
|
185
|
+
eslintConfigJsContent_modified = await (0,runPrettier/* runPrettier */.eY)({
|
186
|
+
sourceCode: eslintConfigJsContent_modified,
|
187
|
+
filePath: eslintConfigJsFilePath
|
188
|
+
});
|
189
|
+
}
|
190
|
+
await promises_.writeFile(eslintConfigJsFilePath, Buffer.from(eslintConfigJsContent_modified, "utf8"));
|
191
|
+
}
|
192
|
+
//# sourceMappingURL=setupEslint.js.map
|
193
|
+
// EXTERNAL MODULE: ./dist/bin/shared/buildContext.js + 3 modules
|
194
|
+
var shared_buildContext = __webpack_require__(85400);
|
195
|
+
// EXTERNAL MODULE: ./dist/bin/shared/customHandler_delegate.js + 1 modules
|
196
|
+
var customHandler_delegate = __webpack_require__(72138);
|
197
|
+
// EXTERNAL MODULE: ./node_modules/zod/lib/index.mjs
|
198
|
+
var zod_lib = __webpack_require__(52300);
|
199
|
+
// EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
|
200
|
+
var assert = __webpack_require__(29041);
|
201
|
+
// EXTERNAL MODULE: ./node_modules/tsafe/esm/id.mjs
|
202
|
+
var id = __webpack_require__(38469);
|
203
|
+
// EXTERNAL MODULE: ./node_modules/cli-select/dist/index.js
|
204
|
+
var dist = __webpack_require__(99398);
|
205
|
+
var dist_default = /*#__PURE__*/__webpack_require__.n(dist);
|
206
|
+
// EXTERNAL MODULE: ./dist/bin/shared/constants.js
|
207
|
+
var constants = __webpack_require__(173);
|
208
|
+
// EXTERNAL MODULE: ./node_modules/chalk/source/index.js
|
209
|
+
var source = __webpack_require__(78818);
|
210
|
+
var source_default = /*#__PURE__*/__webpack_require__.n(source);
|
211
|
+
;// CONCATENATED MODULE: ./dist/bin/init/init.js
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
async function command(params) {
|
228
|
+
const { projectDirPath } = params;
|
229
|
+
await setupVitePluginIfNeeded({ projectDirPath });
|
230
|
+
const buildContext = (0,shared_buildContext/* getBuildContext */.s)({ projectDirPath });
|
231
|
+
const { hasBeenHandled } = await (0,customHandler_delegate/* maybeDelegateCommandToCustomHandler */.q)({
|
232
|
+
commandName: "init",
|
233
|
+
buildContext
|
234
|
+
});
|
235
|
+
if (hasBeenHandled) {
|
236
|
+
return;
|
237
|
+
}
|
238
|
+
await setupEslint({ projectDirPath });
|
239
|
+
let doAddRunDevScript = false;
|
240
|
+
setup_src: {
|
241
|
+
if (buildContext.bundler !== "vite") {
|
242
|
+
break setup_src;
|
243
|
+
}
|
244
|
+
const srcDirPath = (0,external_path_.join)(buildContext.projectDirPath, "src");
|
245
|
+
const mainTsxFilePath = (0,external_path_.join)(srcDirPath, "main.tsx");
|
246
|
+
if (!(await (0,fs_existsAsync/* existsAsync */.o)(mainTsxFilePath))) {
|
247
|
+
break setup_src;
|
248
|
+
}
|
249
|
+
const isAlreadySetup = await (async () => {
|
250
|
+
if (buildContext.themeSrcDirPath !== srcDirPath) {
|
251
|
+
return true;
|
252
|
+
}
|
253
|
+
{
|
254
|
+
const basenames = await promises_.readdir(srcDirPath);
|
255
|
+
for (const basename of basenames) {
|
256
|
+
const path = (0,external_path_.join)(srcDirPath, basename);
|
257
|
+
if (!(await promises_.stat(path)).isFile()) {
|
258
|
+
continue;
|
259
|
+
}
|
260
|
+
if ((await promises_.readFile(path)).toString("utf8").includes("./kc.gen")) {
|
261
|
+
return true;
|
262
|
+
}
|
263
|
+
}
|
264
|
+
}
|
265
|
+
for (const themeType of [...constants/* THEME_TYPES */.Jh, "email"]) {
|
266
|
+
if (!(await (0,fs_existsAsync/* existsAsync */.o)((0,external_path_.join)(srcDirPath, themeType)))) {
|
267
|
+
continue;
|
268
|
+
}
|
269
|
+
return true;
|
270
|
+
}
|
271
|
+
return false;
|
272
|
+
})();
|
273
|
+
if (isAlreadySetup) {
|
274
|
+
break setup_src;
|
275
|
+
}
|
276
|
+
const doSetupAsStandalone = await (async () => {
|
277
|
+
const relativeProjectDirPath = (0,external_path_.relative)(process.cwd(), buildContext.projectDirPath);
|
278
|
+
console.log(source_default().cyan([
|
279
|
+
relativeProjectDirPath === ""
|
280
|
+
? "This Vite project"
|
281
|
+
: `The Vite project at ${relativeProjectDirPath}`,
|
282
|
+
"is it dedicated *only* to building a Keycloak theme?"
|
283
|
+
].join(" ")));
|
284
|
+
const YES = "Yes — this project is only for the Keycloak theme (recommended)";
|
285
|
+
const NO = "No — I'm building an app and a Keycloak theme in the same project (advanced)";
|
286
|
+
const { value } = await dist_default()({ values: [YES, NO] }).catch(() => {
|
287
|
+
process.exit(-1);
|
288
|
+
});
|
289
|
+
console.log(`${value}\n`);
|
290
|
+
return value === YES;
|
291
|
+
})();
|
292
|
+
let files;
|
293
|
+
if (doSetupAsStandalone) {
|
294
|
+
const viteEnvDTsFilePath = (0,external_path_.join)(buildContext.themeSrcDirPath, "vite-env.d.ts");
|
295
|
+
const viteEnvDTsContent = await promises_.readFile(viteEnvDTsFilePath);
|
296
|
+
await promises_.rm(srcDirPath, { recursive: true });
|
297
|
+
await promises_.mkdir(srcDirPath);
|
298
|
+
await promises_.writeFile(viteEnvDTsFilePath, viteEnvDTsContent);
|
299
|
+
files = [
|
300
|
+
{
|
301
|
+
relativeFilePath: "main.tsx",
|
302
|
+
fileContent: [
|
303
|
+
`if (window.kcContext !== undefined) {`,
|
304
|
+
` import("./main-kc");`,
|
305
|
+
`} else {`,
|
306
|
+
` import("./main-kc.dev");`,
|
307
|
+
`}`
|
308
|
+
].join("\n")
|
309
|
+
},
|
310
|
+
{
|
311
|
+
relativeFilePath: "main-kc.dev.tsx",
|
312
|
+
fileContent: `export {};\n`
|
313
|
+
},
|
314
|
+
{
|
315
|
+
relativeFilePath: "main-kc.tsx",
|
316
|
+
fileContent: [
|
317
|
+
`import { createRoot } from "react-dom/client";`,
|
318
|
+
`import { StrictMode } from "react";`,
|
319
|
+
`import { KcPage } from "./kc.gen";`,
|
320
|
+
``,
|
321
|
+
`if (!window.kcContext) {`,
|
322
|
+
` throw new Error("No Keycloak context");`,
|
323
|
+
`}`,
|
324
|
+
``,
|
325
|
+
`createRoot(document.getElementById("root")!).render(`,
|
326
|
+
` <StrictMode>`,
|
327
|
+
` <KcPage kcContext={window.kcContext} />`,
|
328
|
+
` </StrictMode>`,
|
329
|
+
`);`
|
330
|
+
].join("\n")
|
331
|
+
}
|
332
|
+
];
|
333
|
+
}
|
334
|
+
else {
|
335
|
+
doAddRunDevScript = true;
|
336
|
+
await promises_.copyFile(mainTsxFilePath, (0,external_path_.join)(buildContext.themeSrcDirPath, "main-app.tsx"));
|
337
|
+
files = [
|
338
|
+
{
|
339
|
+
relativeFilePath: "main.tsx",
|
340
|
+
fileContent: [
|
341
|
+
`if (window.kcContext !== undefined) {`,
|
342
|
+
` import("./keycloak-theme/main");`,
|
343
|
+
`} else if (import.meta.env.VITE_KC_DEV === "true") {`,
|
344
|
+
` import("./keycloak-theme/main.dev");`,
|
345
|
+
`} else {`,
|
346
|
+
` import("./main-app");`,
|
347
|
+
`}`,
|
348
|
+
``
|
349
|
+
].join("\n")
|
350
|
+
},
|
351
|
+
{
|
352
|
+
relativeFilePath: (0,external_path_.join)(constants/* KEYCLOAK_THEME */.PC, "main.dev.tsx"),
|
353
|
+
fileContent: `export {};\n`
|
354
|
+
},
|
355
|
+
{
|
356
|
+
relativeFilePath: (0,external_path_.join)(constants/* KEYCLOAK_THEME */.PC, "main.tsx"),
|
357
|
+
fileContent: [
|
358
|
+
`import { createRoot } from "react-dom/client";`,
|
359
|
+
`import { StrictMode } from "react";`,
|
360
|
+
`import { KcPage } from "./kc.gen";`,
|
361
|
+
``,
|
362
|
+
`if (!window.kcContext) {`,
|
363
|
+
` throw new Error("No Keycloak context");`,
|
364
|
+
`}`,
|
365
|
+
``,
|
366
|
+
`createRoot(document.getElementById("root")!).render(`,
|
367
|
+
` <StrictMode>`,
|
368
|
+
` <KcPage kcContext={window.kcContext} />`,
|
369
|
+
` </StrictMode>`,
|
370
|
+
`);`,
|
371
|
+
``
|
372
|
+
].join("\n")
|
373
|
+
}
|
374
|
+
];
|
375
|
+
}
|
376
|
+
for (let { relativeFilePath, fileContent } of files) {
|
377
|
+
const filePath = (0,external_path_.join)(srcDirPath, relativeFilePath);
|
378
|
+
run_prettier: {
|
379
|
+
if (!(await (0,runPrettier/* getIsPrettierAvailable */.MT)())) {
|
380
|
+
break run_prettier;
|
381
|
+
}
|
382
|
+
fileContent = await (0,runPrettier/* runPrettier */.eY)({
|
383
|
+
filePath: filePath,
|
384
|
+
sourceCode: fileContent
|
385
|
+
});
|
386
|
+
}
|
387
|
+
await promises_.writeFile(filePath, Buffer.from(fileContent, "utf8"));
|
388
|
+
}
|
389
|
+
}
|
390
|
+
add_script: {
|
391
|
+
const parsedPackageJson = await (async () => {
|
392
|
+
const zParsedPackageJson = (() => {
|
393
|
+
const zTargetType = zod_lib.z.object({
|
394
|
+
scripts: zod_lib.z.record(zod_lib.z.string(), zod_lib.z.string())
|
395
|
+
});
|
396
|
+
(0,assert/* assert */.h)();
|
397
|
+
return (0,id.id)(zTargetType);
|
398
|
+
})();
|
399
|
+
const parsedPackageJson = JSON.parse((await promises_.readFile(buildContext.packageJsonFilePath)).toString("utf8"));
|
400
|
+
zParsedPackageJson.parse(parsedPackageJson);
|
401
|
+
(0,assert/* assert */.h)((0,assert.is)(parsedPackageJson));
|
402
|
+
return parsedPackageJson;
|
403
|
+
})();
|
404
|
+
const SCRIPT_NAME = "build-keycloak-theme";
|
405
|
+
if (SCRIPT_NAME in parsedPackageJson.scripts) {
|
406
|
+
break add_script;
|
407
|
+
}
|
408
|
+
parsedPackageJson.scripts[SCRIPT_NAME] = "npm run build && keycloakify build";
|
409
|
+
if (doAddRunDevScript) {
|
410
|
+
parsedPackageJson.scripts["dev-keycloak-theme"] =
|
411
|
+
"VITE_KC_DEV=true npm run dev";
|
412
|
+
}
|
413
|
+
let packageJson_content = JSON.stringify(parsedPackageJson, null, 2);
|
414
|
+
run_prettier: {
|
415
|
+
if (!(await (0,runPrettier/* getIsPrettierAvailable */.MT)())) {
|
416
|
+
break run_prettier;
|
417
|
+
}
|
418
|
+
packageJson_content = await (0,runPrettier/* runPrettier */.eY)({
|
419
|
+
filePath: buildContext.packageJsonFilePath,
|
420
|
+
sourceCode: packageJson_content
|
421
|
+
});
|
422
|
+
}
|
423
|
+
await promises_.writeFile(buildContext.packageJsonFilePath, Buffer.from(packageJson_content, "utf8"));
|
424
|
+
}
|
425
|
+
const themeType = await (async () => {
|
426
|
+
const values = [...constants/* THEME_TYPES */.Jh, "email"].filter(themeType => {
|
427
|
+
const wrap = buildContext.implementedThemeTypes[themeType];
|
428
|
+
return !wrap.isImplemented && !wrap.isImplemented_native;
|
429
|
+
});
|
430
|
+
if (values.length === 0) {
|
431
|
+
return undefined;
|
432
|
+
}
|
433
|
+
console.log(source_default().cyan(`\nWhich theme theme type would you like to initialize?`));
|
434
|
+
const { value } = await dist_default()({
|
435
|
+
values
|
436
|
+
}).catch(() => {
|
437
|
+
process.exit(-1);
|
438
|
+
});
|
439
|
+
console.log(value);
|
440
|
+
return value;
|
441
|
+
})();
|
442
|
+
if (themeType === undefined) {
|
443
|
+
console.log(source_default().gray("You already have implemented a theme type of every kind, exiting"));
|
444
|
+
process.exit(0);
|
445
|
+
}
|
446
|
+
switch (themeType) {
|
447
|
+
case "account":
|
448
|
+
{
|
449
|
+
const { command } = await __webpack_require__.e(/* import() */ 311).then(__webpack_require__.bind(__webpack_require__, 75780));
|
450
|
+
await command({ buildContext });
|
451
|
+
}
|
452
|
+
return;
|
453
|
+
case "admin":
|
454
|
+
{
|
455
|
+
const { command } = await Promise.all(/* import() */[__webpack_require__.e(502), __webpack_require__.e(626)]).then(__webpack_require__.bind(__webpack_require__, 60355));
|
456
|
+
await command({ buildContext });
|
457
|
+
}
|
458
|
+
return;
|
459
|
+
case "email":
|
460
|
+
{
|
461
|
+
const { command } = await Promise.all(/* import() */[__webpack_require__.e(502), __webpack_require__.e(675)]).then(__webpack_require__.bind(__webpack_require__, 16932));
|
462
|
+
await command({ buildContext });
|
463
|
+
}
|
464
|
+
return;
|
465
|
+
case "login":
|
466
|
+
{
|
467
|
+
const { command } = await Promise.all(/* import() */[__webpack_require__.e(502), __webpack_require__.e(254)]).then(__webpack_require__.bind(__webpack_require__, 2254));
|
468
|
+
await command({ buildContext });
|
469
|
+
}
|
470
|
+
return;
|
471
|
+
}
|
472
|
+
assert/* assert */.h;
|
473
|
+
}
|
474
|
+
//# sourceMappingURL=init.js.map
|
475
|
+
;// CONCATENATED MODULE: ./dist/bin/init/index.js
|
476
|
+
|
477
|
+
//# sourceMappingURL=index.js.map
|
478
|
+
|
479
|
+
/***/ }),
|
480
|
+
|
481
|
+
/***/ 72138:
|
482
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
483
|
+
|
484
|
+
|
485
|
+
// EXPORTS
|
486
|
+
__webpack_require__.d(__webpack_exports__, {
|
487
|
+
"q": () => (/* binding */ maybeDelegateCommandToCustomHandler)
|
488
|
+
});
|
489
|
+
|
490
|
+
// EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
|
491
|
+
var esm_assert = __webpack_require__(29041);
|
492
|
+
// EXTERNAL MODULE: ./dist/bin/shared/constants.js
|
493
|
+
var constants = __webpack_require__(173);
|
494
|
+
;// CONCATENATED MODULE: ./dist/bin/shared/customHandler.js
|
495
|
+
|
496
|
+
|
497
|
+
const BIN_NAME = "_keycloakify-custom-handler";
|
498
|
+
const NOT_IMPLEMENTED_EXIT_CODE = 78;
|
499
|
+
function readParams(params) {
|
500
|
+
const { apiVersion } = params;
|
501
|
+
assert(apiVersion === "v1");
|
502
|
+
const commandName = (() => {
|
503
|
+
const envValue = process.env[CUSTOM_HANDLER_ENV_NAMES.COMMAND_NAME];
|
504
|
+
assert(envValue !== undefined);
|
505
|
+
return envValue;
|
506
|
+
})();
|
507
|
+
const buildContext = (() => {
|
508
|
+
const envValue = process.env[CUSTOM_HANDLER_ENV_NAMES.BUILD_CONTEXT];
|
509
|
+
assert(envValue !== undefined);
|
510
|
+
return JSON.parse(envValue);
|
511
|
+
})();
|
512
|
+
return { commandName, buildContext };
|
513
|
+
}
|
514
|
+
//# sourceMappingURL=customHandler.js.map
|
515
|
+
// EXTERNAL MODULE: external "child_process"
|
516
|
+
var external_child_process_ = __webpack_require__(32081);
|
517
|
+
// EXTERNAL MODULE: ./dist/bin/tools/nodeModulesBinDirPath.js
|
518
|
+
var tools_nodeModulesBinDirPath = __webpack_require__(73776);
|
519
|
+
// EXTERNAL MODULE: external "fs"
|
520
|
+
var external_fs_ = __webpack_require__(57147);
|
521
|
+
;// CONCATENATED MODULE: ./dist/bin/shared/customHandler_delegate.js
|
522
|
+
|
523
|
+
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
|
528
|
+
(0,esm_assert/* assert */.h)();
|
529
|
+
async function maybeDelegateCommandToCustomHandler(params) {
|
530
|
+
const { commandName, buildContext } = params;
|
531
|
+
const nodeModulesBinDirPath = await (0,tools_nodeModulesBinDirPath/* getNodeModulesBinDirPath */.K)({
|
532
|
+
packageJsonFilePath: buildContext.packageJsonFilePath
|
533
|
+
});
|
534
|
+
if (!external_fs_.readdirSync(nodeModulesBinDirPath).includes(BIN_NAME)) {
|
535
|
+
return { hasBeenHandled: false };
|
536
|
+
}
|
537
|
+
try {
|
538
|
+
external_child_process_.execSync(`npx ${BIN_NAME}`, {
|
539
|
+
stdio: "inherit",
|
540
|
+
env: Object.assign(Object.assign({}, process.env), { [constants/* CUSTOM_HANDLER_ENV_NAMES.COMMAND_NAME */._S.COMMAND_NAME]: commandName, [constants/* CUSTOM_HANDLER_ENV_NAMES.BUILD_CONTEXT */._S.BUILD_CONTEXT]: JSON.stringify(buildContext) })
|
541
|
+
});
|
542
|
+
}
|
543
|
+
catch (error) {
|
544
|
+
const status = error.status;
|
545
|
+
if (status === NOT_IMPLEMENTED_EXIT_CODE) {
|
546
|
+
return { hasBeenHandled: false };
|
547
|
+
}
|
548
|
+
process.exit(status);
|
549
|
+
}
|
550
|
+
return { hasBeenHandled: true };
|
551
|
+
}
|
552
|
+
//# sourceMappingURL=customHandler_delegate.js.map
|
553
|
+
|
554
|
+
/***/ }),
|
555
|
+
|
556
|
+
/***/ 43765:
|
557
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
558
|
+
|
559
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
560
|
+
/* harmony export */ "o": () => (/* binding */ existsAsync)
|
561
|
+
/* harmony export */ });
|
562
|
+
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73292);
|
563
|
+
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__);
|
564
|
+
|
565
|
+
async function existsAsync(path) {
|
566
|
+
try {
|
567
|
+
await fs_promises__WEBPACK_IMPORTED_MODULE_0__.stat(path);
|
568
|
+
return true;
|
569
|
+
}
|
570
|
+
catch (error) {
|
571
|
+
if (error.code === "ENOENT")
|
572
|
+
return false;
|
573
|
+
throw error;
|
574
|
+
}
|
575
|
+
}
|
576
|
+
//# sourceMappingURL=fs.existsAsync.js.map
|
577
|
+
|
578
|
+
/***/ }),
|
579
|
+
|
580
|
+
/***/ 93721:
|
581
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
582
|
+
|
583
|
+
|
584
|
+
// EXPORTS
|
585
|
+
__webpack_require__.d(__webpack_exports__, {
|
586
|
+
"p": () => (/* binding */ getInstalledModuleDirPath)
|
587
|
+
});
|
588
|
+
|
589
|
+
// EXTERNAL MODULE: external "path"
|
590
|
+
var external_path_ = __webpack_require__(71017);
|
591
|
+
// EXTERNAL MODULE: ./dist/bin/tools/fs.existsAsync.js
|
592
|
+
var fs_existsAsync = __webpack_require__(43765);
|
593
|
+
// EXTERNAL MODULE: external "child_process"
|
594
|
+
var external_child_process_ = __webpack_require__(32081);
|
595
|
+
// EXTERNAL MODULE: ./node_modules/tsafe/esm/assert.mjs + 1 modules
|
596
|
+
var assert = __webpack_require__(29041);
|
597
|
+
;// CONCATENATED MODULE: ./dist/bin/tools/isRootPath.js
|
598
|
+
|
599
|
+
function getIsRootPath(filePath) {
|
600
|
+
const path_normalized = (0,external_path_.normalize)(filePath);
|
601
|
+
// Unix-like root ("/")
|
602
|
+
if (path_normalized === "/") {
|
603
|
+
return true;
|
604
|
+
}
|
605
|
+
// Check for Windows drive root (e.g., "C:\\")
|
606
|
+
if (/^[a-zA-Z]:\\$/.test(path_normalized)) {
|
607
|
+
return true;
|
608
|
+
}
|
609
|
+
// Check for UNC root (e.g., "\\server\share")
|
610
|
+
if (/^\\\\[^\\]+\\[^\\]+\\?$/.test(path_normalized)) {
|
611
|
+
return true;
|
612
|
+
}
|
613
|
+
return false;
|
614
|
+
}
|
615
|
+
//# sourceMappingURL=isRootPath.js.map
|
616
|
+
;// CONCATENATED MODULE: ./dist/bin/tools/getInstalledModuleDirPath.js
|
617
|
+
|
618
|
+
|
619
|
+
|
620
|
+
|
621
|
+
|
622
|
+
async function getInstalledModuleDirPath(params) {
|
623
|
+
const { moduleName, packageJsonDirPath } = params;
|
624
|
+
{
|
625
|
+
let dirPath = packageJsonDirPath;
|
626
|
+
while (true) {
|
627
|
+
const dirPath_candidate = (0,external_path_.join)(dirPath, "node_modules", ...moduleName.split("/"));
|
628
|
+
let doesExist;
|
629
|
+
try {
|
630
|
+
doesExist = await (0,fs_existsAsync/* existsAsync */.o)(dirPath_candidate);
|
631
|
+
}
|
632
|
+
catch (_a) {
|
633
|
+
doesExist = false;
|
634
|
+
}
|
635
|
+
if (doesExist) {
|
636
|
+
return dirPath_candidate;
|
637
|
+
}
|
638
|
+
if (getIsRootPath(dirPath)) {
|
639
|
+
break;
|
640
|
+
}
|
641
|
+
dirPath = (0,external_path_.join)(dirPath, "..");
|
642
|
+
}
|
643
|
+
}
|
644
|
+
const dirPath = external_child_process_.execSync(`npm list ${moduleName}`, {
|
645
|
+
cwd: packageJsonDirPath
|
646
|
+
})
|
647
|
+
.toString("utf8")
|
648
|
+
.trim();
|
649
|
+
(0,assert/* assert */.h)(dirPath !== "");
|
650
|
+
return dirPath;
|
651
|
+
}
|
652
|
+
//# sourceMappingURL=getInstalledModuleDirPath.js.map
|
653
|
+
|
654
|
+
/***/ }),
|
655
|
+
|
656
|
+
/***/ 73776:
|
657
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
658
|
+
|
659
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
660
|
+
/* harmony export */ "K": () => (/* binding */ getNodeModulesBinDirPath)
|
661
|
+
/* harmony export */ });
|
662
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(71017);
|
663
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
|
664
|
+
/* harmony import */ var _getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(58822);
|
665
|
+
/* harmony import */ var _getInstalledModuleDirPath__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(93721);
|
666
|
+
/* harmony import */ var _fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(43765);
|
667
|
+
/* harmony import */ var zod__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(52300);
|
668
|
+
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(73292);
|
669
|
+
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_4__);
|
670
|
+
/* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(29041);
|
671
|
+
/* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(38469);
|
672
|
+
|
673
|
+
|
674
|
+
|
675
|
+
|
676
|
+
|
677
|
+
|
678
|
+
|
679
|
+
|
680
|
+
let cache_bestEffort = undefined;
|
681
|
+
/** NOTE: Careful, this function can fail when the binary
|
682
|
+
* Used is not in the node_modules directory of the project
|
683
|
+
* (for example when running tests with vscode extension we'll get
|
684
|
+
* '/Users/dylan/.vscode/extensions/vitest.explorer-1.16.0/dist/worker.js'
|
685
|
+
*
|
686
|
+
* instead of
|
687
|
+
* '/Users/joseph/.nvm/versions/node/v22.12.0/bin/node'
|
688
|
+
* or
|
689
|
+
* '/Users/joseph/github/keycloakify-starter/node_modules/.bin/vite'
|
690
|
+
*
|
691
|
+
* as the value of process.argv[1]
|
692
|
+
*/
|
693
|
+
function getNodeModulesBinDirPath_bestEffort() {
|
694
|
+
if (cache_bestEffort !== undefined) {
|
695
|
+
return cache_bestEffort;
|
696
|
+
}
|
697
|
+
const binPath = process.argv[1];
|
698
|
+
special_case_running_not_from_distribution: {
|
699
|
+
if (!binPath.endsWith(".ts")) {
|
700
|
+
break special_case_running_not_from_distribution;
|
701
|
+
}
|
702
|
+
const packageJsonDirPath = (0,_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__/* .getNearestPackageJsonDirPath */ .B)((0,path__WEBPACK_IMPORTED_MODULE_0__.dirname)(binPath));
|
703
|
+
const nodeModulesBinDirPath = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(packageJsonDirPath, "node_modules", ".bin");
|
704
|
+
return nodeModulesBinDirPath;
|
705
|
+
}
|
706
|
+
const segments = [".bin"];
|
707
|
+
let foundNodeModules = false;
|
708
|
+
for (const segment of binPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep).reverse()) {
|
709
|
+
skip_segment: {
|
710
|
+
if (foundNodeModules) {
|
711
|
+
break skip_segment;
|
712
|
+
}
|
713
|
+
if (segment === "node_modules") {
|
714
|
+
foundNodeModules = true;
|
715
|
+
break skip_segment;
|
716
|
+
}
|
717
|
+
continue;
|
718
|
+
}
|
719
|
+
segments.unshift(segment);
|
720
|
+
}
|
721
|
+
if (!foundNodeModules) {
|
722
|
+
throw new Error(`Could not find node_modules in path ${binPath}`);
|
723
|
+
}
|
724
|
+
const nodeModulesBinDirPath = segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep);
|
725
|
+
cache_bestEffort = nodeModulesBinDirPath;
|
726
|
+
return nodeModulesBinDirPath;
|
727
|
+
}
|
728
|
+
let cache_withPackageJsonFileDirPath = undefined;
|
729
|
+
async function getNodeModulesBinDirPath_withPackageJsonFileDirPath(params) {
|
730
|
+
const { packageJsonFilePath } = params;
|
731
|
+
use_cache: {
|
732
|
+
if (cache_withPackageJsonFileDirPath === undefined) {
|
733
|
+
break use_cache;
|
734
|
+
}
|
735
|
+
if (cache_withPackageJsonFileDirPath.packageJsonFilePath !== packageJsonFilePath) {
|
736
|
+
cache_withPackageJsonFileDirPath = undefined;
|
737
|
+
break use_cache;
|
738
|
+
}
|
739
|
+
return cache_withPackageJsonFileDirPath.nodeModulesBinDirPath;
|
740
|
+
}
|
741
|
+
// [...]node_modules/keycloakify
|
742
|
+
const installedModuleDirPath = await (0,_getInstalledModuleDirPath__WEBPACK_IMPORTED_MODULE_2__/* .getInstalledModuleDirPath */ .p)({
|
743
|
+
// Here it will always be "keycloakify" but since we are in tools/ we make something generic
|
744
|
+
moduleName: await (async () => {
|
745
|
+
const zParsedPackageJson = (() => {
|
746
|
+
const zTargetType = zod__WEBPACK_IMPORTED_MODULE_6__.z.object({
|
747
|
+
name: zod__WEBPACK_IMPORTED_MODULE_6__.z.string()
|
748
|
+
});
|
749
|
+
tsafe_assert__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .h;
|
750
|
+
return (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(zTargetType);
|
751
|
+
})();
|
752
|
+
const parsedPackageJson = JSON.parse((await fs_promises__WEBPACK_IMPORTED_MODULE_4__.readFile((0,path__WEBPACK_IMPORTED_MODULE_0__.join)((0,_getThisCodebaseRootDirPath__WEBPACK_IMPORTED_MODULE_1__/* .getThisCodebaseRootDirPath */ .e)(), "package.json"))).toString("utf8"));
|
753
|
+
zParsedPackageJson.parse(parsedPackageJson);
|
754
|
+
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_5__/* .assert */ .h)((0,tsafe_assert__WEBPACK_IMPORTED_MODULE_5__.is)(parsedPackageJson));
|
755
|
+
return parsedPackageJson.name;
|
756
|
+
})(),
|
757
|
+
packageJsonDirPath: (0,path__WEBPACK_IMPORTED_MODULE_0__.dirname)(packageJsonFilePath)
|
758
|
+
});
|
759
|
+
const segments = installedModuleDirPath.split(path__WEBPACK_IMPORTED_MODULE_0__.sep);
|
760
|
+
while (true) {
|
761
|
+
const segment = segments.pop();
|
762
|
+
if (segment === undefined) {
|
763
|
+
throw new Error(`Could not find .bin directory relative to ${packageJsonFilePath}`);
|
764
|
+
}
|
765
|
+
if (segment !== "node_modules") {
|
766
|
+
continue;
|
767
|
+
}
|
768
|
+
const candidate = (0,path__WEBPACK_IMPORTED_MODULE_0__.join)(segments.join(path__WEBPACK_IMPORTED_MODULE_0__.sep), segment, ".bin");
|
769
|
+
if (!(await (0,_fs_existsAsync__WEBPACK_IMPORTED_MODULE_3__/* .existsAsync */ .o)(candidate))) {
|
770
|
+
continue;
|
771
|
+
}
|
772
|
+
cache_withPackageJsonFileDirPath = {
|
773
|
+
packageJsonFilePath,
|
774
|
+
nodeModulesBinDirPath: candidate
|
775
|
+
};
|
776
|
+
break;
|
777
|
+
}
|
778
|
+
return cache_withPackageJsonFileDirPath.nodeModulesBinDirPath;
|
779
|
+
}
|
780
|
+
function getNodeModulesBinDirPath(params) {
|
781
|
+
const { packageJsonFilePath } = params !== null && params !== void 0 ? params : {};
|
782
|
+
return packageJsonFilePath === undefined
|
783
|
+
? getNodeModulesBinDirPath_bestEffort()
|
784
|
+
: getNodeModulesBinDirPath_withPackageJsonFileDirPath({ packageJsonFilePath });
|
785
|
+
}
|
786
|
+
//# sourceMappingURL=nodeModulesBinDirPath.js.map
|
787
|
+
|
788
|
+
/***/ }),
|
789
|
+
|
790
|
+
/***/ 48433:
|
791
|
+
/***/ ((module, __webpack_exports__, __webpack_require__) => {
|
792
|
+
|
793
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
794
|
+
/* harmony export */ "LG": () => (/* binding */ getPrettier),
|
795
|
+
/* harmony export */ "MT": () => (/* binding */ getIsPrettierAvailable),
|
796
|
+
/* harmony export */ "eY": () => (/* binding */ runPrettier)
|
797
|
+
/* harmony export */ });
|
798
|
+
/* harmony import */ var _nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(73776);
|
799
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(71017);
|
800
|
+
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
|
801
|
+
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(73292);
|
802
|
+
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_2__);
|
803
|
+
/* harmony import */ var tsafe_id__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(38469);
|
804
|
+
/* harmony import */ var tsafe_assert__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29041);
|
805
|
+
/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(78818);
|
806
|
+
/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_4__);
|
807
|
+
/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(6113);
|
808
|
+
/* harmony import */ var crypto__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(crypto__WEBPACK_IMPORTED_MODULE_5__);
|
809
|
+
/* harmony import */ var tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(76030);
|
810
|
+
/* harmony import */ var _readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(64795);
|
811
|
+
/* module decorator */ module = __webpack_require__.hmd(module);
|
812
|
+
|
813
|
+
|
814
|
+
|
815
|
+
|
816
|
+
|
817
|
+
|
818
|
+
|
819
|
+
|
820
|
+
|
821
|
+
getIsPrettierAvailable.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
|
822
|
+
async function getIsPrettierAvailable() {
|
823
|
+
var _a;
|
824
|
+
if (getIsPrettierAvailable.cache !== undefined) {
|
825
|
+
return getIsPrettierAvailable.cache;
|
826
|
+
}
|
827
|
+
const nodeModulesBinDirPath = (0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)({
|
828
|
+
packageJsonFilePath: undefined
|
829
|
+
});
|
830
|
+
const prettierBinPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.join)(nodeModulesBinDirPath, "prettier");
|
831
|
+
const stats = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.stat(prettierBinPath).catch(() => undefined);
|
832
|
+
const isPrettierAvailable = (_a = stats === null || stats === void 0 ? void 0 : stats.isFile()) !== null && _a !== void 0 ? _a : false;
|
833
|
+
getIsPrettierAvailable.cache = isPrettierAvailable;
|
834
|
+
return isPrettierAvailable;
|
835
|
+
}
|
836
|
+
getPrettier.cache = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
|
837
|
+
async function getPrettier() {
|
838
|
+
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(getIsPrettierAvailable());
|
839
|
+
if (getPrettier.cache !== undefined) {
|
840
|
+
return getPrettier.cache;
|
841
|
+
}
|
842
|
+
let prettier = (0,tsafe_id__WEBPACK_IMPORTED_MODULE_7__.id)(undefined);
|
843
|
+
import_prettier: {
|
844
|
+
// NOTE: When module is linked we want to make sure we import the correct version
|
845
|
+
// of prettier, that is the one of the project, not the one of this repo.
|
846
|
+
// So we do a sketchy eval to bypass ncc.
|
847
|
+
// We make sure to only do that when linking, otherwise we import properly.
|
848
|
+
if ((0,_readThisNpmPackageVersion__WEBPACK_IMPORTED_MODULE_6__/* .readThisNpmPackageVersion */ .K)().startsWith("0.0.0")) {
|
849
|
+
const prettierDirPath = (0,path__WEBPACK_IMPORTED_MODULE_1__.resolve)((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)({ packageJsonFilePath: undefined }), "..", "prettier"));
|
850
|
+
const isCJS = true && module.exports;
|
851
|
+
if (isCJS) {
|
852
|
+
eval(`${(0,tsafe_symToStr__WEBPACK_IMPORTED_MODULE_8__/* .symToStr */ .r)({ prettier })} = require("${prettierDirPath}")`);
|
853
|
+
}
|
854
|
+
else {
|
855
|
+
prettier = await new Promise(_resolve => {
|
856
|
+
eval(`import("file:///${(0,path__WEBPACK_IMPORTED_MODULE_1__.join)(prettierDirPath, "index.mjs").replace(/\\/g, "/")}").then(prettier => _resolve(prettier))`);
|
857
|
+
});
|
858
|
+
}
|
859
|
+
(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__/* .assert */ .h)(!(0,tsafe_assert__WEBPACK_IMPORTED_MODULE_3__.is)(prettier));
|
860
|
+
break import_prettier;
|
861
|
+
}
|
862
|
+
prettier = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 79421, 23));
|
863
|
+
}
|
864
|
+
const configHash = await (async () => {
|
865
|
+
const configFilePath = await prettier.resolveConfigFile((0,path__WEBPACK_IMPORTED_MODULE_1__.join)((0,_nodeModulesBinDirPath__WEBPACK_IMPORTED_MODULE_0__/* .getNodeModulesBinDirPath */ .K)({ packageJsonFilePath: undefined }), "..", ".."));
|
866
|
+
if (configFilePath === null) {
|
867
|
+
return "";
|
868
|
+
}
|
869
|
+
const data = await fs_promises__WEBPACK_IMPORTED_MODULE_2__.readFile(configFilePath);
|
870
|
+
return crypto__WEBPACK_IMPORTED_MODULE_5__.createHash("sha256").update(data).digest("hex");
|
871
|
+
})();
|
872
|
+
const prettierAndConfig = {
|
873
|
+
prettier,
|
874
|
+
configHash
|
875
|
+
};
|
876
|
+
getPrettier.cache = prettierAndConfig;
|
877
|
+
return prettierAndConfig;
|
878
|
+
}
|
879
|
+
async function runPrettier(params) {
|
880
|
+
const { sourceCode, filePath } = params;
|
881
|
+
let formattedSourceCode;
|
882
|
+
try {
|
883
|
+
const { prettier } = await getPrettier();
|
884
|
+
const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
|
885
|
+
resolveConfig: true
|
886
|
+
});
|
887
|
+
if (ignored || inferredParser === null) {
|
888
|
+
return sourceCode;
|
889
|
+
}
|
890
|
+
const config = await prettier.resolveConfig(filePath);
|
891
|
+
formattedSourceCode = await prettier.format(typeof sourceCode === "string" ? sourceCode : sourceCode.toString("utf8"), Object.assign(Object.assign({}, config), { filePath, parser: inferredParser }));
|
892
|
+
}
|
893
|
+
catch (error) {
|
894
|
+
console.log(chalk__WEBPACK_IMPORTED_MODULE_4___default().red(`You probably need to upgrade the version of prettier in your project`));
|
895
|
+
throw error;
|
896
|
+
}
|
897
|
+
return typeof sourceCode === "string"
|
898
|
+
? formattedSourceCode
|
899
|
+
: Buffer.from(formattedSourceCode, "utf8");
|
900
|
+
}
|
901
|
+
//# sourceMappingURL=runPrettier.js.map
|
902
|
+
|
903
|
+
/***/ }),
|
904
|
+
|
905
|
+
/***/ 18512:
|
906
|
+
/***/ ((module) => {
|
907
|
+
|
908
|
+
|
909
|
+
const x = module.exports;
|
910
|
+
const ESC = '\u001B[';
|
911
|
+
const OSC = '\u001B]';
|
912
|
+
const BEL = '\u0007';
|
913
|
+
const SEP = ';';
|
914
|
+
const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal';
|
915
|
+
|
916
|
+
x.cursorTo = (x, y) => {
|
917
|
+
if (typeof x !== 'number') {
|
918
|
+
throw new TypeError('The `x` argument is required');
|
919
|
+
}
|
920
|
+
|
921
|
+
if (typeof y !== 'number') {
|
922
|
+
return ESC + (x + 1) + 'G';
|
923
|
+
}
|
924
|
+
|
925
|
+
return ESC + (y + 1) + ';' + (x + 1) + 'H';
|
926
|
+
};
|
927
|
+
|
928
|
+
x.cursorMove = (x, y) => {
|
929
|
+
if (typeof x !== 'number') {
|
930
|
+
throw new TypeError('The `x` argument is required');
|
931
|
+
}
|
932
|
+
|
933
|
+
let ret = '';
|
934
|
+
|
935
|
+
if (x < 0) {
|
936
|
+
ret += ESC + (-x) + 'D';
|
937
|
+
} else if (x > 0) {
|
938
|
+
ret += ESC + x + 'C';
|
939
|
+
}
|
940
|
+
|
941
|
+
if (y < 0) {
|
942
|
+
ret += ESC + (-y) + 'A';
|
943
|
+
} else if (y > 0) {
|
944
|
+
ret += ESC + y + 'B';
|
945
|
+
}
|
946
|
+
|
947
|
+
return ret;
|
948
|
+
};
|
949
|
+
|
950
|
+
x.cursorUp = count => ESC + (typeof count === 'number' ? count : 1) + 'A';
|
951
|
+
x.cursorDown = count => ESC + (typeof count === 'number' ? count : 1) + 'B';
|
952
|
+
x.cursorForward = count => ESC + (typeof count === 'number' ? count : 1) + 'C';
|
953
|
+
x.cursorBackward = count => ESC + (typeof count === 'number' ? count : 1) + 'D';
|
954
|
+
|
955
|
+
x.cursorLeft = ESC + 'G';
|
956
|
+
x.cursorSavePosition = ESC + (isTerminalApp ? '7' : 's');
|
957
|
+
x.cursorRestorePosition = ESC + (isTerminalApp ? '8' : 'u');
|
958
|
+
x.cursorGetPosition = ESC + '6n';
|
959
|
+
x.cursorNextLine = ESC + 'E';
|
960
|
+
x.cursorPrevLine = ESC + 'F';
|
961
|
+
x.cursorHide = ESC + '?25l';
|
962
|
+
x.cursorShow = ESC + '?25h';
|
963
|
+
|
964
|
+
x.eraseLines = count => {
|
965
|
+
let clear = '';
|
966
|
+
|
967
|
+
for (let i = 0; i < count; i++) {
|
968
|
+
clear += x.eraseLine + (i < count - 1 ? x.cursorUp() : '');
|
969
|
+
}
|
970
|
+
|
971
|
+
if (count) {
|
972
|
+
clear += x.cursorLeft;
|
973
|
+
}
|
974
|
+
|
975
|
+
return clear;
|
976
|
+
};
|
977
|
+
|
978
|
+
x.eraseEndLine = ESC + 'K';
|
979
|
+
x.eraseStartLine = ESC + '1K';
|
980
|
+
x.eraseLine = ESC + '2K';
|
981
|
+
x.eraseDown = ESC + 'J';
|
982
|
+
x.eraseUp = ESC + '1J';
|
983
|
+
x.eraseScreen = ESC + '2J';
|
984
|
+
x.scrollUp = ESC + 'S';
|
985
|
+
x.scrollDown = ESC + 'T';
|
986
|
+
|
987
|
+
x.clearScreen = '\u001Bc';
|
988
|
+
|
989
|
+
x.clearTerminal = process.platform === 'win32' ?
|
990
|
+
`${x.eraseScreen}${ESC}0f` :
|
991
|
+
// 1. Erases the screen (Only done in case `2` is not supported)
|
992
|
+
// 2. Erases the whole screen including scrollback buffer
|
993
|
+
// 3. Moves cursor to the top-left position
|
994
|
+
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
|
995
|
+
`${x.eraseScreen}${ESC}3J${ESC}H`;
|
996
|
+
|
997
|
+
x.beep = BEL;
|
998
|
+
|
999
|
+
x.link = (text, url) => {
|
1000
|
+
return [
|
1001
|
+
OSC,
|
1002
|
+
'8',
|
1003
|
+
SEP,
|
1004
|
+
SEP,
|
1005
|
+
url,
|
1006
|
+
BEL,
|
1007
|
+
text,
|
1008
|
+
OSC,
|
1009
|
+
'8',
|
1010
|
+
SEP,
|
1011
|
+
SEP,
|
1012
|
+
BEL
|
1013
|
+
].join('');
|
1014
|
+
};
|
1015
|
+
|
1016
|
+
x.image = (buf, opts) => {
|
1017
|
+
opts = opts || {};
|
1018
|
+
|
1019
|
+
let ret = OSC + '1337;File=inline=1';
|
1020
|
+
|
1021
|
+
if (opts.width) {
|
1022
|
+
ret += `;width=${opts.width}`;
|
1023
|
+
}
|
1024
|
+
|
1025
|
+
if (opts.height) {
|
1026
|
+
ret += `;height=${opts.height}`;
|
1027
|
+
}
|
1028
|
+
|
1029
|
+
if (opts.preserveAspectRatio === false) {
|
1030
|
+
ret += ';preserveAspectRatio=0';
|
1031
|
+
}
|
1032
|
+
|
1033
|
+
return ret + ':' + buf.toString('base64') + BEL;
|
1034
|
+
};
|
1035
|
+
|
1036
|
+
x.iTerm = {};
|
1037
|
+
|
1038
|
+
x.iTerm.setCwd = cwd => OSC + '50;CurrentDir=' + (cwd || process.cwd()) + BEL;
|
1039
|
+
|
1040
|
+
|
1041
|
+
/***/ }),
|
1042
|
+
|
1043
|
+
/***/ 39340:
|
1044
|
+
/***/ ((__unused_webpack_module, exports) => {
|
1045
|
+
|
1046
|
+
|
1047
|
+
|
1048
|
+
Object.defineProperty(exports, "__esModule", ({
|
1049
|
+
value: true
|
1050
|
+
}));
|
1051
|
+
exports.withPromise = exports.withCallback = void 0;
|
1052
|
+
|
1053
|
+
/**
|
1054
|
+
* Open the input with a normal callback function
|
1055
|
+
*
|
1056
|
+
* @param {Input} input - input object
|
1057
|
+
* @param {function} valueMapper - function which maps the resulting id and value back to the expected format
|
1058
|
+
* @param {function} callback - callback function
|
1059
|
+
*/
|
1060
|
+
const withCallback = (input, valueMapper, callback) => {
|
1061
|
+
input.open();
|
1062
|
+
input.onSelect((id, value) => callback(valueMapper(id, value)));
|
1063
|
+
};
|
1064
|
+
/**
|
1065
|
+
* Open the input with a promise
|
1066
|
+
*
|
1067
|
+
* @param {Input} input - input object
|
1068
|
+
* @param {function} valueMapper - function which maps the resulting id and value back to the expected format
|
1069
|
+
*/
|
1070
|
+
|
1071
|
+
|
1072
|
+
exports.withCallback = withCallback;
|
1073
|
+
|
1074
|
+
const withPromise = (input, valueMapper) => {
|
1075
|
+
return new Promise((resolve, reject) => {
|
1076
|
+
input.open();
|
1077
|
+
input.onSelect((id, value) => {
|
1078
|
+
if (id === null) {
|
1079
|
+
reject();
|
1080
|
+
} else {
|
1081
|
+
resolve(valueMapper(id, value));
|
1082
|
+
}
|
1083
|
+
});
|
1084
|
+
});
|
1085
|
+
};
|
1086
|
+
|
1087
|
+
exports.withPromise = withPromise;
|
1088
|
+
|
1089
|
+
/***/ }),
|
1090
|
+
|
1091
|
+
/***/ 99398:
|
1092
|
+
/***/ ((module, exports, __webpack_require__) => {
|
1093
|
+
|
1094
|
+
|
1095
|
+
|
1096
|
+
Object.defineProperty(exports, "__esModule", ({
|
1097
|
+
value: true
|
1098
|
+
}));
|
1099
|
+
exports["default"] = void 0;
|
1100
|
+
|
1101
|
+
var _input = _interopRequireDefault(__webpack_require__(25730));
|
1102
|
+
|
1103
|
+
var _renderer = _interopRequireDefault(__webpack_require__(16059));
|
1104
|
+
|
1105
|
+
var _callbackMappers = __webpack_require__(39340);
|
1106
|
+
|
1107
|
+
var _valueMappers = __webpack_require__(26730);
|
1108
|
+
|
1109
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
1110
|
+
|
1111
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
1112
|
+
|
1113
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
1114
|
+
|
1115
|
+
/**
|
1116
|
+
* Default options
|
1117
|
+
*/
|
1118
|
+
const defaultOptions = {
|
1119
|
+
outputStream: process.stdout,
|
1120
|
+
inputStream: process.stdin,
|
1121
|
+
values: [],
|
1122
|
+
defaultValue: 0,
|
1123
|
+
selected: '(x)',
|
1124
|
+
unselected: '( )',
|
1125
|
+
indentation: 0,
|
1126
|
+
cleanup: true,
|
1127
|
+
valueRenderer: value => value
|
1128
|
+
};
|
1129
|
+
/**
|
1130
|
+
* Create an instance of cli-select with the given options
|
1131
|
+
*
|
1132
|
+
* @param {object} options - options for cli-select
|
1133
|
+
* @param {function} callback - if specified, a callback will be used, otherwise a promise gets returned (optional)
|
1134
|
+
*/
|
1135
|
+
|
1136
|
+
const creator = (options, callback) => {
|
1137
|
+
// merge options with default options
|
1138
|
+
options = _objectSpread({}, defaultOptions, options); // create renderer and input instances
|
1139
|
+
|
1140
|
+
const renderer = new _renderer.default(options, options.outputStream);
|
1141
|
+
const input = new _input.default(options.inputStream);
|
1142
|
+
input.setDefaultValue(options.defaultValue);
|
1143
|
+
input.attachRenderer(renderer); // handle array and object values
|
1144
|
+
|
1145
|
+
let valueMapper;
|
1146
|
+
|
1147
|
+
if (Array.isArray(options.values)) {
|
1148
|
+
valueMapper = (0, _valueMappers.withArrayValues)(options);
|
1149
|
+
} else {
|
1150
|
+
valueMapper = (0, _valueMappers.withObjectValues)(options);
|
1151
|
+
} // map values
|
1152
|
+
|
1153
|
+
|
1154
|
+
options.values = valueMapper.input;
|
1155
|
+
input.setValues(options.values); // handle different callback methods
|
1156
|
+
|
1157
|
+
if (typeof callback === 'function') {
|
1158
|
+
return (0, _callbackMappers.withCallback)(input, valueMapper.output, callback);
|
1159
|
+
} else {
|
1160
|
+
return (0, _callbackMappers.withPromise)(input, valueMapper.output);
|
1161
|
+
}
|
1162
|
+
};
|
1163
|
+
|
1164
|
+
exports = module.exports = creator;
|
1165
|
+
Object.defineProperty(exports, "__esModule", ({
|
1166
|
+
value: true
|
1167
|
+
}));
|
1168
|
+
var _default = creator;
|
1169
|
+
exports["default"] = _default;
|
1170
|
+
|
1171
|
+
/***/ }),
|
1172
|
+
|
1173
|
+
/***/ 25730:
|
1174
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
1175
|
+
|
1176
|
+
|
1177
|
+
|
1178
|
+
Object.defineProperty(exports, "__esModule", ({
|
1179
|
+
value: true
|
1180
|
+
}));
|
1181
|
+
exports["default"] = void 0;
|
1182
|
+
|
1183
|
+
var _readline = _interopRequireDefault(__webpack_require__(14521));
|
1184
|
+
|
1185
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
1186
|
+
|
1187
|
+
/**
|
1188
|
+
* Handle cli input
|
1189
|
+
*/
|
1190
|
+
class Input {
|
1191
|
+
/**
|
1192
|
+
* Input constructor
|
1193
|
+
*
|
1194
|
+
* @param {any} stream - stream to catch (optional)
|
1195
|
+
*/
|
1196
|
+
constructor(stream = process.stdin) {
|
1197
|
+
// set default values
|
1198
|
+
this.stream = stream;
|
1199
|
+
this.values = [];
|
1200
|
+
this.selectedValue = 0;
|
1201
|
+
|
1202
|
+
this.onSelectListener = () => {};
|
1203
|
+
|
1204
|
+
this.onKeyPress = this.onKeyPress.bind(this);
|
1205
|
+
}
|
1206
|
+
/**
|
1207
|
+
* Set the available values
|
1208
|
+
*
|
1209
|
+
* @param {array} values - all available values
|
1210
|
+
*/
|
1211
|
+
|
1212
|
+
|
1213
|
+
setValues(values) {
|
1214
|
+
this.values = values;
|
1215
|
+
|
1216
|
+
if (this.renderer) {
|
1217
|
+
this.renderer.setValues(values);
|
1218
|
+
}
|
1219
|
+
}
|
1220
|
+
/**
|
1221
|
+
* Set the default value
|
1222
|
+
*
|
1223
|
+
* @param {number} defaultValue - default value id
|
1224
|
+
*/
|
1225
|
+
|
1226
|
+
|
1227
|
+
setDefaultValue(defaultValue) {
|
1228
|
+
this.selectedValue = defaultValue;
|
1229
|
+
}
|
1230
|
+
/**
|
1231
|
+
* Attach a renderer to the input catcher
|
1232
|
+
*
|
1233
|
+
* @param {Renderer} renderer - renderer to use for rendering responses
|
1234
|
+
*/
|
1235
|
+
|
1236
|
+
|
1237
|
+
attachRenderer(renderer) {
|
1238
|
+
this.renderer = renderer;
|
1239
|
+
this.renderer.setValues(this.values);
|
1240
|
+
}
|
1241
|
+
/**
|
1242
|
+
* Register an on select listener
|
1243
|
+
*
|
1244
|
+
* @param {function} listener - listener function which receives two parameters: valueId and value
|
1245
|
+
*/
|
1246
|
+
|
1247
|
+
|
1248
|
+
onSelect(listener) {
|
1249
|
+
this.onSelectListener = listener;
|
1250
|
+
}
|
1251
|
+
/**
|
1252
|
+
* Open the stream and listen for input
|
1253
|
+
*/
|
1254
|
+
|
1255
|
+
|
1256
|
+
open() {
|
1257
|
+
// register keypress event
|
1258
|
+
_readline.default.emitKeypressEvents(this.stream); // handle keypress
|
1259
|
+
|
1260
|
+
|
1261
|
+
this.stream.on('keypress', this.onKeyPress); // initially render the response
|
1262
|
+
|
1263
|
+
if (this.renderer) {
|
1264
|
+
this.renderer.render(this.selectedValue);
|
1265
|
+
} // hide pressed keys and start listening on input
|
1266
|
+
|
1267
|
+
|
1268
|
+
this.stream.setRawMode(true);
|
1269
|
+
this.stream.resume();
|
1270
|
+
}
|
1271
|
+
/**
|
1272
|
+
* Close the stream
|
1273
|
+
*
|
1274
|
+
* @param {boolean} cancelled - true if no value was selected (optional)
|
1275
|
+
*/
|
1276
|
+
|
1277
|
+
|
1278
|
+
close(cancelled = false) {
|
1279
|
+
// reset stream properties
|
1280
|
+
this.stream.setRawMode(false);
|
1281
|
+
this.stream.pause(); // cleanup the output
|
1282
|
+
|
1283
|
+
if (this.renderer) {
|
1284
|
+
this.renderer.cleanup();
|
1285
|
+
} // call the on select listener
|
1286
|
+
|
1287
|
+
|
1288
|
+
if (cancelled) {
|
1289
|
+
this.onSelectListener(null);
|
1290
|
+
} else {
|
1291
|
+
this.onSelectListener(this.selectedValue, this.values[this.selectedValue]);
|
1292
|
+
}
|
1293
|
+
|
1294
|
+
this.stream.removeListener('keypress', this.onKeyPress);
|
1295
|
+
}
|
1296
|
+
/**
|
1297
|
+
* Render the response
|
1298
|
+
*/
|
1299
|
+
|
1300
|
+
|
1301
|
+
render() {
|
1302
|
+
if (!this.renderer) {
|
1303
|
+
return;
|
1304
|
+
}
|
1305
|
+
|
1306
|
+
this.renderer.render(this.selectedValue);
|
1307
|
+
}
|
1308
|
+
/**
|
1309
|
+
* Handle key press event
|
1310
|
+
*
|
1311
|
+
* @param {string} string - input string
|
1312
|
+
* @param {object} key - object containing information about the pressed key
|
1313
|
+
*/
|
1314
|
+
|
1315
|
+
|
1316
|
+
onKeyPress(string, key) {
|
1317
|
+
if (key) {
|
1318
|
+
if (key.name === 'up' && this.selectedValue > 0) {
|
1319
|
+
this.selectedValue--;
|
1320
|
+
this.render();
|
1321
|
+
} else if (key.name === 'down' && this.selectedValue + 1 < this.values.length) {
|
1322
|
+
this.selectedValue++;
|
1323
|
+
this.render();
|
1324
|
+
} else if (key.name === 'return') {
|
1325
|
+
this.close();
|
1326
|
+
} else if (key.name === 'escape' || key.name === 'c' && key.ctrl) {
|
1327
|
+
this.close(true);
|
1328
|
+
}
|
1329
|
+
}
|
1330
|
+
}
|
1331
|
+
|
1332
|
+
}
|
1333
|
+
|
1334
|
+
exports["default"] = Input;
|
1335
|
+
|
1336
|
+
/***/ }),
|
1337
|
+
|
1338
|
+
/***/ 16059:
|
1339
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
1340
|
+
|
1341
|
+
|
1342
|
+
|
1343
|
+
Object.defineProperty(exports, "__esModule", ({
|
1344
|
+
value: true
|
1345
|
+
}));
|
1346
|
+
exports["default"] = void 0;
|
1347
|
+
|
1348
|
+
var _readline = _interopRequireDefault(__webpack_require__(14521));
|
1349
|
+
|
1350
|
+
var _ansiEscapes = __webpack_require__(18512);
|
1351
|
+
|
1352
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
1353
|
+
|
1354
|
+
/**
|
1355
|
+
* Response renderer
|
1356
|
+
*/
|
1357
|
+
class Renderer {
|
1358
|
+
/**
|
1359
|
+
* Renderer constructor
|
1360
|
+
*
|
1361
|
+
* @param {object} options - renderer options
|
1362
|
+
* @param {any} stream - stream to write to (optional)
|
1363
|
+
*/
|
1364
|
+
constructor(options, stream = process.stdout) {
|
1365
|
+
this.options = options;
|
1366
|
+
this.stream = stream;
|
1367
|
+
this.values = [];
|
1368
|
+
this.initialRender = true;
|
1369
|
+
}
|
1370
|
+
/**
|
1371
|
+
* Set the available values
|
1372
|
+
*
|
1373
|
+
* @param {array} values - all available values
|
1374
|
+
*/
|
1375
|
+
|
1376
|
+
|
1377
|
+
setValues(values) {
|
1378
|
+
this.values = values;
|
1379
|
+
}
|
1380
|
+
/**
|
1381
|
+
* Render the values
|
1382
|
+
*
|
1383
|
+
* @param {number} selectedValue - selected value (optional)
|
1384
|
+
*/
|
1385
|
+
|
1386
|
+
|
1387
|
+
render(selectedValue = 0) {
|
1388
|
+
if (this.initialRender) {
|
1389
|
+
// hide the cursor initially
|
1390
|
+
this.initialRender = false;
|
1391
|
+
this.stream.write(_ansiEscapes.cursorHide);
|
1392
|
+
} else {
|
1393
|
+
// remove previous lines and values
|
1394
|
+
this.stream.write((0, _ansiEscapes.eraseLines)(this.values.length));
|
1395
|
+
} // output the current values
|
1396
|
+
|
1397
|
+
|
1398
|
+
this.values.forEach((value, index) => {
|
1399
|
+
const symbol = selectedValue === index ? this.options.selected : this.options.unselected;
|
1400
|
+
const indentation = ' '.repeat(this.options.indentation);
|
1401
|
+
const renderedValue = this.options.valueRenderer(value, selectedValue === index);
|
1402
|
+
const end = index !== this.values.length - 1 ? '\n' : '';
|
1403
|
+
this.stream.write(indentation + symbol + ' ' + renderedValue + end);
|
1404
|
+
});
|
1405
|
+
}
|
1406
|
+
/**
|
1407
|
+
* Cleanup the console at the end
|
1408
|
+
*/
|
1409
|
+
|
1410
|
+
|
1411
|
+
cleanup() {
|
1412
|
+
this.stream.write((0, _ansiEscapes.eraseLines)(this.values.length));
|
1413
|
+
this.stream.write(_ansiEscapes.cursorShow);
|
1414
|
+
}
|
1415
|
+
|
1416
|
+
}
|
1417
|
+
|
1418
|
+
exports["default"] = Renderer;
|
1419
|
+
|
1420
|
+
/***/ }),
|
1421
|
+
|
1422
|
+
/***/ 26730:
|
1423
|
+
/***/ ((__unused_webpack_module, exports) => {
|
1424
|
+
|
1425
|
+
|
1426
|
+
|
1427
|
+
Object.defineProperty(exports, "__esModule", ({
|
1428
|
+
value: true
|
1429
|
+
}));
|
1430
|
+
exports.withObjectValues = exports.withArrayValues = void 0;
|
1431
|
+
|
1432
|
+
/**
|
1433
|
+
* Map incoming and outgoing values if the initial values are an array
|
1434
|
+
*
|
1435
|
+
* @param {object} options - cli-select options
|
1436
|
+
*/
|
1437
|
+
const withArrayValues = options => {
|
1438
|
+
return {
|
1439
|
+
input: options.values,
|
1440
|
+
output: (id, value) => {
|
1441
|
+
return {
|
1442
|
+
id,
|
1443
|
+
value
|
1444
|
+
};
|
1445
|
+
}
|
1446
|
+
};
|
1447
|
+
};
|
1448
|
+
/**
|
1449
|
+
* Map incoming and outgoing values if the initial values are an object
|
1450
|
+
*
|
1451
|
+
* @param {object} options - cli-select options
|
1452
|
+
*/
|
1453
|
+
|
1454
|
+
|
1455
|
+
exports.withArrayValues = withArrayValues;
|
1456
|
+
|
1457
|
+
const withObjectValues = options => {
|
1458
|
+
const originalValues = options.values;
|
1459
|
+
return {
|
1460
|
+
input: Object.values(originalValues),
|
1461
|
+
output: (id, value) => {
|
1462
|
+
return {
|
1463
|
+
id: Object.keys(originalValues)[id],
|
1464
|
+
value
|
1465
|
+
};
|
1466
|
+
}
|
1467
|
+
};
|
1468
|
+
};
|
1469
|
+
|
1470
|
+
exports.withObjectValues = withObjectValues;
|
1471
|
+
|
1472
|
+
/***/ })
|
1473
|
+
|
1474
|
+
};
|
1475
|
+
;
|