create-sitecore-jss 22.2.0-canary.5 → 22.2.0-canary.51
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/dist/bin.js +17 -42
- package/dist/common/index.js +5 -3
- package/dist/common/processes/install.js +1 -1
- package/dist/common/processes/next.js +6 -3
- package/dist/common/processes/transform.js +19 -19
- package/dist/common/prompts/base.js +0 -25
- package/dist/common/prompts/proxy.js +35 -0
- package/dist/common/prompts/sxp.js +34 -0
- package/dist/common/utils/helpers.js +29 -19
- package/dist/init-runner.js +6 -3
- package/dist/initializers/angular/index.js +0 -3
- package/dist/initializers/angular/prompts.js +6 -6
- package/dist/initializers/angular-sxp/index.js +8 -2
- package/dist/initializers/angular-xmcloud/index.js +28 -4
- package/dist/initializers/nextjs/index.js +2 -2
- package/dist/initializers/nextjs/prompts.js +2 -0
- package/dist/initializers/nextjs/remove-dev-dependencies.js +2 -2
- package/dist/initializers/nextjs-multisite/index.js +1 -1
- package/dist/initializers/nextjs-styleguide/index.js +1 -1
- package/dist/initializers/nextjs-styleguide-tracking/index.js +1 -1
- package/dist/initializers/nextjs-sxa/index.js +1 -1
- package/dist/initializers/nextjs-xmcloud/index.js +1 -1
- package/dist/initializers/node-xmcloud-proxy/index.js +2 -1
- package/dist/initializers/react/index.js +3 -3
- package/dist/initializers/react/prompts.js +1 -1
- package/dist/initializers/react-native/prompts.js +1 -0
- package/dist/initializers/vue/prompts.js +1 -1
- package/dist/templates/angular/.env +4 -5
- package/dist/templates/angular/.eslintrc +1 -0
- package/dist/templates/angular/package.json +0 -2
- package/dist/templates/angular/scripts/config/plugins/fallback.ts +0 -1
- package/dist/templates/angular/scripts/generate-component-factory.ts +8 -0
- package/dist/templates/angular/scripts/generate-config.ts +25 -6
- package/dist/templates/angular/scripts/update-graphql-fragment-data.ts +21 -30
- package/dist/templates/angular/server.bundle.ts +3 -23
- package/dist/templates/angular/server.exports.ts +13 -0
- package/dist/templates/angular/src/app/JssState.ts +2 -9
- package/dist/templates/angular/src/app/app.module.ts +1 -1
- package/dist/templates/angular/src/app/jss-context.server-side.service.ts +4 -2
- package/dist/templates/angular/src/app/jss-context.service.ts +14 -11
- package/dist/templates/angular/src/app/jss-graphql.service.ts +7 -7
- package/dist/templates/angular/src/app/layout/jss-layout.service.ts +2 -2
- package/dist/templates/angular/src/app/lib/dictionary-service-factory.ts +4 -1
- package/dist/templates/angular/src/app/lib/graphql-client-factory/config.ts +21 -0
- package/dist/templates/angular/src/app/lib/graphql-client-factory/index.ts +16 -0
- package/dist/templates/angular/src/app/lib/layout-service-factory.ts +1 -1
- package/dist/templates/angular/src/app/routing/layout/layout.component.ts +10 -9
- package/dist/templates/angular-sxp/.env +2 -0
- package/dist/templates/angular-sxp/scripts/config/plugins/disconnected.ts +4 -2
- package/dist/templates/angular-sxp/src/app/components/graph-ql-layout/graph-ql-layout.component.ts +1 -1
- package/dist/templates/angular-xmcloud/.env +8 -2
- package/dist/templates/angular-xmcloud/angular.json +33 -0
- package/dist/templates/angular-xmcloud/package.json +15 -10
- package/dist/templates/angular-xmcloud/scripts/bootstrap.ts +28 -0
- package/dist/templates/angular-xmcloud/scripts/config/plugins/xmcloud.ts +16 -0
- package/dist/templates/angular-xmcloud/scripts/generate-metadata.ts +25 -0
- package/dist/templates/angular-xmcloud/server.exports.ts +24 -0
- package/dist/templates/angular-xmcloud/src/app/components/app-components.shared.module.ts +21 -0
- package/dist/templates/angular-xmcloud/src/app/components/column-splitter/column-splitter.component.html +5 -0
- package/dist/templates/angular-xmcloud/src/app/components/column-splitter/column-splitter.component.ts +40 -0
- package/dist/templates/angular-xmcloud/src/app/components/container/container.component.html +14 -0
- package/dist/templates/angular-xmcloud/src/app/components/container/container.component.ts +30 -0
- package/dist/templates/angular-xmcloud/src/app/components/image/image.component.html +36 -0
- package/dist/templates/angular-xmcloud/src/app/components/image/image.component.ts +67 -0
- package/dist/templates/angular-xmcloud/src/app/components/link-list/link-list.component.html +15 -0
- package/dist/templates/angular-xmcloud/src/app/components/link-list/link-list.component.ts +41 -0
- package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation-item.component.html +23 -0
- package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation-item.component.ts +65 -0
- package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation.component.html +21 -0
- package/dist/templates/angular-xmcloud/src/app/components/navigation/navigation.component.ts +49 -0
- package/dist/templates/angular-xmcloud/src/app/components/page-content/page-content.component.html +5 -0
- package/dist/templates/angular-xmcloud/src/app/components/page-content/page-content.component.ts +39 -0
- package/dist/templates/angular-xmcloud/src/app/components/partial-design-dynamic-placeholder/partial-design-dynamic-placeholder.component.html +1 -0
- package/dist/templates/angular-xmcloud/src/app/components/partial-design-dynamic-placeholder/partial-design-dynamic-placeholder.component.ts +15 -0
- package/dist/templates/angular-xmcloud/src/app/components/promo/promo.component.html +21 -0
- package/dist/templates/angular-xmcloud/src/app/components/promo/promo.component.ts +13 -0
- package/dist/templates/angular-xmcloud/src/app/components/richtext/richtext.component.html +7 -12
- package/dist/templates/angular-xmcloud/src/app/components/richtext/richtext.component.ts +6 -1
- package/dist/templates/angular-xmcloud/src/app/components/row-splitter/row-splitter.component.html +11 -0
- package/dist/templates/angular-xmcloud/src/app/components/row-splitter/row-splitter.component.ts +35 -0
- package/dist/templates/angular-xmcloud/src/app/components/sxa.component.ts +4 -4
- package/dist/templates/angular-xmcloud/src/app/components/title/title.component.html +10 -0
- package/dist/templates/angular-xmcloud/src/app/components/title/title.component.ts +56 -0
- package/dist/templates/angular-xmcloud/src/app/jss-link.service.ts +55 -0
- package/dist/templates/angular-xmcloud/src/app/lib/config.ts +2 -0
- package/dist/templates/angular-xmcloud/src/app/lib/graphql-client-factory/config.ts +58 -0
- package/dist/templates/angular-xmcloud/src/app/routing/layout/layout.component.html +38 -0
- package/dist/templates/angular-xmcloud/src/app/routing/layout/layout.component.ts +104 -0
- package/dist/templates/angular-xmcloud/src/app/routing/scripts/scripts.component.html +3 -0
- package/dist/templates/angular-xmcloud/src/app/routing/scripts/scripts.module.ts +10 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/basic/_component.scss +48 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/basic/_container.scss +64 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/basic/_fonts.scss +3 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/basic/_footer.scss +31 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/basic/_header.scss +51 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/basic/_navigation.scss +150 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/basic/_promo.scss +58 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/basic/_rich-text.scss +11 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/basic/_variables.scss +10 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/basic/main.scss +8 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/main.scss +14 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/_app.scss +103 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/abstracts/_functions.scss +8 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/abstracts/_mixins.scss +121 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/abstracts/_vars.scss +3 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/abstracts/vars/_colors.scss +283 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/abstracts/vars/_fontSizes.scss +16 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/abstracts/vars/_margins.scss +11 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/fonts/_fonts.scss +1 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/fonts/index.scss +1 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/index.scss +3 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/links/_link-button.scss +26 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/links/index.scss +1 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/reset/_inputs.scss +58 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/reset/_links.scss +14 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/reset/_ui-datepicker.scss +7 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/richtext/_richtext-files-icons.scss +86 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/richtext/_richtext.scss +101 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/richtext/index.scss +2 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/typehead/_typehead.scss +95 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/base/typehead/index.scss +1 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/_component-column-splitter.scss +14 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/_component-container.scss +27 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/_component-image.scss +18 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/_component-navigation.scss +51 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/_component-promo.scss +42 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/_component-richtext-content.scss +19 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/common/_alignment.scss +26 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/common/_boxed.scss +16 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/common/_clearfix.scss +11 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/common/_highlighted.scss +63 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/common/_link-button.scss +16 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/common/_promoted-box.scss +3 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/common/index.scss +6 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/container/_bordered.scss +24 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/container/_title-row-box.scss +66 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/container/index.scss +1 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/image/_image-default-size.scss +6 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/image/index.scss +1 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/image-alignment/_image-left.scss +3 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/image-alignment/_image-right.scss +3 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/index.scss +17 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/layout/_acaindent.scss +5 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/layout/_background.scss +27 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/layout/index.scss +1 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/link-list/_component-link-list.scss +45 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/link-list/_list-vertical.scss +20 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/link-list/index.scss +2 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/navigation/_navigation-fat.scss +58 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/navigation/_navigation-main-horizontal-vertical.scss +176 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/navigation/_navigation-mobile.scss +85 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/navigation/_navigation-sidebar.scss +29 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/navigation/_sitemap-navigation.scss +20 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/navigation/index.scss +5 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/promo/_absolute-bottom-link.scss +8 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/promo/_promo-hero.scss +40 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/promo/_promo-shadow.scss +42 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/promo/index.scss +3 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/rich-text/_rich-text-lists.scss +63 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/rich-text/index.scss +1 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/spacing/_background-colors.scss +14 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/spacing/_indent.scss +13 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/spacing/index.scss +2 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/title/_component-title.scss +30 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/components/title/index.scss +1 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/main.scss +4 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/variants/index.scss +6 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/variants/link-list/index.scss +0 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/variants/navigation/index.scss +0 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/variants/page-content/index.scss +0 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/variants/promo/index.scss +0 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/variants/rich-text/index.scss +0 -0
- package/dist/templates/angular-xmcloud/src/assets/styles/sass/variants/title/index.scss +0 -0
- package/dist/templates/nextjs/package.json +1 -1
- package/dist/templates/nextjs/scripts/config/plugins/fallback.ts +0 -1
- package/dist/templates/nextjs/scripts/generate-config.ts +8 -1
- package/dist/templates/nextjs/src/lib/page-props-factory/plugins/component-props.ts +2 -1
- package/dist/templates/nextjs-styleguide/scripts/config/plugins/disconnected.ts +1 -0
- package/dist/templates/nextjs-sxa/src/assets/sass/components/_component-image.scss +1 -1
- package/dist/templates/nextjs-sxa/src/components/Container.tsx +6 -14
- package/dist/templates/nextjs-xmcloud/src/lib/page-props-factory/plugins/component-themes.ts +2 -1
- package/dist/templates/nextjs-xmcloud/src/lib/page-props-factory/plugins/preview-mode.ts +2 -1
- package/dist/templates/node-headless-ssr-proxy/src/config.ts +3 -3
- package/dist/templates/node-headless-ssr-proxy/src/httpAgents.ts +2 -2
- package/dist/templates/node-headless-ssr-proxy/src/index.ts +9 -2
- package/dist/templates/node-xmcloud-proxy/.env +7 -1
- package/dist/templates/node-xmcloud-proxy/README.md +1 -1
- package/dist/templates/node-xmcloud-proxy/package.json +3 -2
- package/dist/templates/node-xmcloud-proxy/src/config.ts +9 -3
- package/dist/templates/node-xmcloud-proxy/src/index.ts +48 -5
- package/dist/templates/node-xmcloud-proxy/src/types.ts +10 -42
- package/dist/templates/react/scripts/generate-config.js +10 -3
- package/dist/templates/vue/scripts/generate-config.js +5 -0
- package/package.json +2 -2
- package/dist/templates/angular/src/app/lib/graphql-client-factory.ts +0 -28
- package/dist/templates/angular-xmcloud/src/app/lib/graphql-client-factory.ts +0 -44
package/dist/bin.js
CHANGED
|
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.main = exports.promptDestination = exports.
|
|
38
|
+
exports.main = exports.promptDestination = exports.getDestination = exports.parseArgs = void 0;
|
|
39
39
|
const fs_1 = __importDefault(require("fs"));
|
|
40
40
|
const path_1 = __importStar(require("path"));
|
|
41
41
|
const chalk_1 = __importDefault(require("chalk"));
|
|
@@ -43,7 +43,6 @@ const inquirer_1 = __importDefault(require("inquirer"));
|
|
|
43
43
|
const init_runner_1 = require("./init-runner");
|
|
44
44
|
const minimist_1 = __importDefault(require("minimist"));
|
|
45
45
|
const common_1 = require("./common");
|
|
46
|
-
const proxyAppMatcher = /node-.+-proxy/g;
|
|
47
46
|
const parseArgs = () => {
|
|
48
47
|
// parse any command line arguments passed into `init sitecore-jss`
|
|
49
48
|
// to pass to the generator prompts and skip them.
|
|
@@ -71,7 +70,7 @@ const parseArgs = () => {
|
|
|
71
70
|
return args;
|
|
72
71
|
};
|
|
73
72
|
exports.parseArgs = parseArgs;
|
|
74
|
-
const
|
|
73
|
+
const getDestination = (args, templates) => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
74
|
if (templates.length === 0) {
|
|
76
75
|
throw new Error('Unable to get destinations, provided templates are empty');
|
|
77
76
|
}
|
|
@@ -83,29 +82,9 @@ const getDestinations = (args, templates) => __awaiter(void 0, void 0, void 0, f
|
|
|
83
82
|
? defaultBaseDestination
|
|
84
83
|
: yield (0, exports.promptDestination)('Where would you like your new app created?', defaultBaseDestination);
|
|
85
84
|
}
|
|
86
|
-
|
|
87
|
-
const proxyApp = templates.find((template) => template.match(proxyAppMatcher));
|
|
88
|
-
if (proxyApp) {
|
|
89
|
-
const defaultProxyDestination = proxyApp && `${process.cwd()}${path_1.sep}${proxyApp}`;
|
|
90
|
-
let proxyAppDestination = args.proxyAppDestination;
|
|
91
|
-
if (!proxyAppDestination) {
|
|
92
|
-
proxyAppDestination = args.yes
|
|
93
|
-
? defaultProxyDestination
|
|
94
|
-
: yield (0, exports.promptDestination)('Where would you like your proxy app created?', defaultProxyDestination);
|
|
95
|
-
}
|
|
96
|
-
while (proxyAppDestination === destination) {
|
|
97
|
-
proxyAppDestination = yield (0, exports.promptDestination)('Proxy app and base app cannot be located in the same folder. Please input another path for proxy', defaultProxyDestination);
|
|
98
|
-
}
|
|
99
|
-
return {
|
|
100
|
-
destination,
|
|
101
|
-
proxyAppDestination,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
return {
|
|
105
|
-
destination,
|
|
106
|
-
};
|
|
85
|
+
return destination;
|
|
107
86
|
});
|
|
108
|
-
exports.
|
|
87
|
+
exports.getDestination = getDestination;
|
|
109
88
|
const promptDestination = (prompt, defaultDestination) => __awaiter(void 0, void 0, void 0, function* () {
|
|
110
89
|
return (yield inquirer_1.default.prompt({
|
|
111
90
|
type: 'input',
|
|
@@ -152,24 +131,20 @@ const main = (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
152
131
|
});
|
|
153
132
|
templates.push(answer.template);
|
|
154
133
|
}
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
});
|
|
165
|
-
if (!answer.continue) {
|
|
166
|
-
process.exit();
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
args.force = true;
|
|
134
|
+
const destination = yield (0, exports.getDestination)(args, templates);
|
|
135
|
+
if (!args.force && fs_1.default.existsSync(destination) && fs_1.default.readdirSync(destination).length > 0) {
|
|
136
|
+
const answer = yield inquirer_1.default.prompt({
|
|
137
|
+
type: 'confirm',
|
|
138
|
+
name: 'continue',
|
|
139
|
+
message: `Directory '${destination}' not empty. Are you sure you want to continue?`,
|
|
140
|
+
});
|
|
141
|
+
if (!answer.continue) {
|
|
142
|
+
process.exit();
|
|
171
143
|
}
|
|
172
144
|
}
|
|
145
|
+
else {
|
|
146
|
+
args.force = true;
|
|
147
|
+
}
|
|
173
148
|
if (!args.yes) {
|
|
174
149
|
if (args.prePushHook === null) {
|
|
175
150
|
const answer = yield inquirer_1.default.prompt({
|
|
@@ -187,7 +162,7 @@ const main = (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
187
162
|
}
|
|
188
163
|
}
|
|
189
164
|
try {
|
|
190
|
-
yield (0, init_runner_1.initRunner)(templates.slice(), Object.assign(Object.assign(
|
|
165
|
+
yield (0, init_runner_1.initRunner)(templates.slice(), Object.assign(Object.assign({}, args), { destination, templates }));
|
|
191
166
|
}
|
|
192
167
|
catch (error) {
|
|
193
168
|
console.log(chalk_1.default.red('An error occurred: ', error));
|
package/dist/common/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.installPrePushHook = exports.lintFix = exports.installPackages = exports.nextSteps = exports.transform = exports.removeFile = exports.saveConfiguration = exports.getBaseTemplates = exports.getAllTemplates = exports.
|
|
3
|
+
exports.installPrePushHook = exports.lintFix = exports.installPackages = exports.nextSteps = exports.transform = exports.removeFile = exports.saveConfiguration = exports.getBaseTemplates = exports.getAllTemplates = exports.writeJsonFile = exports.openJsonFile = exports.isDevEnvironment = exports.sxpPrompts = exports.styleguidePrompts = exports.missingAddonMsg = exports.incompatibleAddonsMsg = exports.DEFAULT_APPNAME = exports.clientAppPrompts = void 0;
|
|
4
4
|
var base_1 = require("./prompts/base");
|
|
5
5
|
Object.defineProperty(exports, "clientAppPrompts", { enumerable: true, get: function () { return base_1.clientAppPrompts; } });
|
|
6
6
|
Object.defineProperty(exports, "DEFAULT_APPNAME", { enumerable: true, get: function () { return base_1.DEFAULT_APPNAME; } });
|
|
@@ -8,10 +8,12 @@ Object.defineProperty(exports, "incompatibleAddonsMsg", { enumerable: true, get:
|
|
|
8
8
|
Object.defineProperty(exports, "missingAddonMsg", { enumerable: true, get: function () { return base_1.missingAddonMsg; } });
|
|
9
9
|
var styleguide_1 = require("./prompts/styleguide");
|
|
10
10
|
Object.defineProperty(exports, "styleguidePrompts", { enumerable: true, get: function () { return styleguide_1.styleguidePrompts; } });
|
|
11
|
+
var sxp_1 = require("./prompts/sxp");
|
|
12
|
+
Object.defineProperty(exports, "sxpPrompts", { enumerable: true, get: function () { return sxp_1.sxpPrompts; } });
|
|
11
13
|
var helpers_1 = require("./utils/helpers");
|
|
12
14
|
Object.defineProperty(exports, "isDevEnvironment", { enumerable: true, get: function () { return helpers_1.isDevEnvironment; } });
|
|
13
|
-
Object.defineProperty(exports, "
|
|
14
|
-
Object.defineProperty(exports, "
|
|
15
|
+
Object.defineProperty(exports, "openJsonFile", { enumerable: true, get: function () { return helpers_1.openJsonFile; } });
|
|
16
|
+
Object.defineProperty(exports, "writeJsonFile", { enumerable: true, get: function () { return helpers_1.writeJsonFile; } });
|
|
15
17
|
Object.defineProperty(exports, "getAllTemplates", { enumerable: true, get: function () { return helpers_1.getAllTemplates; } });
|
|
16
18
|
Object.defineProperty(exports, "getBaseTemplates", { enumerable: true, get: function () { return helpers_1.getBaseTemplates; } });
|
|
17
19
|
Object.defineProperty(exports, "saveConfiguration", { enumerable: true, get: function () { return helpers_1.saveConfiguration; } });
|
|
@@ -85,5 +85,5 @@ const installPrePushHook = (destination, silent) => __awaiter(void 0, void 0, vo
|
|
|
85
85
|
exports.installPrePushHook = installPrePushHook;
|
|
86
86
|
const getPackageJson = (projectFolder) => {
|
|
87
87
|
const packagePath = path_1.default.join(projectFolder, 'package.json');
|
|
88
|
-
return (0, helpers_1.
|
|
88
|
+
return (0, helpers_1.openJsonFile)(packagePath);
|
|
89
89
|
};
|
|
@@ -16,10 +16,13 @@ exports.nextSteps = void 0;
|
|
|
16
16
|
const chalk_1 = __importDefault(require("chalk"));
|
|
17
17
|
/**
|
|
18
18
|
* Logs app creation completion message and next steps
|
|
19
|
-
* @param {string}
|
|
19
|
+
* @param {string[]} appNames application name(s) for the new app
|
|
20
20
|
* @param {string[]} nextStepsArr next steps to be performed after app is created
|
|
21
21
|
*/
|
|
22
|
-
const nextSteps = (
|
|
22
|
+
const nextSteps = (appNames, nextStepsArr) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
const successMessage = appNames.length > 1
|
|
24
|
+
? `JSS applications ${chalk_1.default.green(appNames.join(', '))} are ready!`
|
|
25
|
+
: `JSS application ${chalk_1.default.green(appNames[0])} is ready!`;
|
|
23
26
|
console.log(chalk_1.default.red(' -/oyhdmNNNNmdhyo/- '));
|
|
24
27
|
console.log(chalk_1.default.red(' :sdMMMMMMMMMMMMMMMMMMMMds: '));
|
|
25
28
|
console.log(chalk_1.default.red(' :yNMMMMMMMMMMMMMMMMMMMMMMMMMMNy: '));
|
|
@@ -51,7 +54,7 @@ const nextSteps = (appName, nextStepsArr) => __awaiter(void 0, void 0, void 0, f
|
|
|
51
54
|
console.log(chalk_1.default.white(' / // /\\ \\_\\ \\ '));
|
|
52
55
|
console.log(chalk_1.default.white(' \\___/___/___/'));
|
|
53
56
|
console.log();
|
|
54
|
-
console.log(
|
|
57
|
+
console.log(successMessage);
|
|
55
58
|
console.log();
|
|
56
59
|
console.log(chalk_1.default.yellow('Next steps:'));
|
|
57
60
|
nextStepsArr.forEach((step) => {
|
|
@@ -35,7 +35,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.transform = exports.diffAndWriteFiles = exports.diffFiles = exports.mergeEnv = exports.merge = exports.transformFilename = void 0;
|
|
38
|
+
exports.transform = exports.populateEjsData = exports.diffAndWriteFiles = exports.diffFiles = exports.mergeEnv = exports.merge = exports.transformFilename = void 0;
|
|
39
39
|
const chalk_1 = __importDefault(require("chalk"));
|
|
40
40
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
41
41
|
const glob_1 = __importDefault(require("glob"));
|
|
@@ -180,6 +180,16 @@ const diffAndWriteFiles = ({ rendered, pathToNewFile, answers, }) => __awaiter(v
|
|
|
180
180
|
}
|
|
181
181
|
});
|
|
182
182
|
exports.diffAndWriteFiles = diffAndWriteFiles;
|
|
183
|
+
const populateEjsData = (answers, destination) => {
|
|
184
|
+
// pass in helper to answers object
|
|
185
|
+
const ejsData = Object.assign(Object.assign({}, answers), { helper: {
|
|
186
|
+
isDev: (0, helpers_1.isDevEnvironment)(destination || answers.destination),
|
|
187
|
+
getPascalCaseName: helpers_1.getPascalCaseName,
|
|
188
|
+
getAppPrefix: helpers_1.getAppPrefix,
|
|
189
|
+
} });
|
|
190
|
+
return ejsData;
|
|
191
|
+
};
|
|
192
|
+
exports.populateEjsData = populateEjsData;
|
|
183
193
|
/**
|
|
184
194
|
* Handles each template file and applies ejs renderer, also:
|
|
185
195
|
* * determines files for copy
|
|
@@ -194,21 +204,11 @@ exports.diffAndWriteFiles = diffAndWriteFiles;
|
|
|
194
204
|
*/
|
|
195
205
|
const transform = (templatePath, answers, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
196
206
|
const { isFileForCopy, isFileForSkip, fileForCopyRegExp = FILE_FOR_COPY_REGEXP } = options;
|
|
197
|
-
|
|
198
|
-
// allow proxy app to be installed separately alongside base app
|
|
199
|
-
if (templatePath.match(/.*node-.+-proxy$/g)) {
|
|
200
|
-
destination = answers.proxyAppDestination;
|
|
201
|
-
}
|
|
202
|
-
const destinationPath = path_1.default.resolve(destination || answers.destination);
|
|
207
|
+
const destinationPath = path_1.default.resolve(answers.destination);
|
|
203
208
|
if (!answers.appPrefix) {
|
|
204
209
|
answers.appPrefix = false;
|
|
205
210
|
}
|
|
206
|
-
|
|
207
|
-
const ejsData = Object.assign(Object.assign({}, answers), { helper: {
|
|
208
|
-
isDev: (0, helpers_1.isDevEnvironment)(destination || answers.destination),
|
|
209
|
-
getPascalCaseName: helpers_1.getPascalCaseName,
|
|
210
|
-
getAppPrefix: helpers_1.getAppPrefix,
|
|
211
|
-
} });
|
|
211
|
+
const ejsData = (0, exports.populateEjsData)(answers);
|
|
212
212
|
// the templates to be run through ejs render or copied directly
|
|
213
213
|
const files = glob_1.default.sync('**/*', { cwd: templatePath, dot: true, nodir: true });
|
|
214
214
|
for (const file of files) {
|
|
@@ -233,13 +233,13 @@ const transform = (templatePath, answers, options = {}) => __awaiter(void 0, voi
|
|
|
233
233
|
fs_extra_1.default.copySync(pathToTemplate, pathToNewFile);
|
|
234
234
|
continue;
|
|
235
235
|
}
|
|
236
|
-
if (file.endsWith('
|
|
237
|
-
// we treat
|
|
238
|
-
// read the current
|
|
239
|
-
const
|
|
240
|
-
const
|
|
236
|
+
if (file.endsWith('.json') && fs_extra_1.default.existsSync(pathToNewFile)) {
|
|
237
|
+
// we treat a .json a bit differently
|
|
238
|
+
// read the current .json and the template .json (rendered with ejs)
|
|
239
|
+
const currentJson = (0, helpers_1.openJsonFile)(pathToNewFile);
|
|
240
|
+
const templateJson = JSON.parse(yield (0, ejs_1.renderFile)(path_1.default.resolve(pathToTemplate), ejsData));
|
|
241
241
|
// merge them and set the result to str which will then go through diff
|
|
242
|
-
const merged = (0, exports.merge)(
|
|
242
|
+
const merged = (0, exports.merge)(currentJson, templateJson);
|
|
243
243
|
str = JSON.stringify(merged, null, 2);
|
|
244
244
|
}
|
|
245
245
|
if (file.endsWith('.env') && fs_extra_1.default.existsSync(pathToNewFile)) {
|
|
@@ -38,31 +38,6 @@ exports.clientAppPrompts = [
|
|
|
38
38
|
return !answers.appName;
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
|
-
{
|
|
42
|
-
type: 'input',
|
|
43
|
-
name: 'hostName',
|
|
44
|
-
message: 'What is your Sitecore hostname (used if deployed to Sitecore)?',
|
|
45
|
-
default: (answers) => `${answers.appName}.dev.local`,
|
|
46
|
-
when: (answers) => {
|
|
47
|
-
if (answers.yes && !answers.hostName) {
|
|
48
|
-
answers.hostName = `${answers.appName}.dev.local`;
|
|
49
|
-
}
|
|
50
|
-
return !answers.hostName;
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
type: 'list',
|
|
55
|
-
name: 'fetchWith',
|
|
56
|
-
message: 'How would you like to fetch Layout and Dictionary data?',
|
|
57
|
-
choices: Object.values(FetchWith),
|
|
58
|
-
default: exports.DEFAULT_FETCHWITH,
|
|
59
|
-
when: (answers) => {
|
|
60
|
-
if (answers.yes && !answers.fetchWith) {
|
|
61
|
-
answers.fetchWith = exports.DEFAULT_FETCHWITH;
|
|
62
|
-
}
|
|
63
|
-
return !answers.fetchWith;
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
41
|
];
|
|
67
42
|
const missingAddonMsg = (source, missingAddon) => chalk_1.default.yellow(`Warning: ${source} add-on cannot be used without the ${missingAddon} add-on. This may cause unexpected results.`);
|
|
68
43
|
exports.missingAddonMsg = missingAddonMsg;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.proxyPrompts = exports.FALLBACK_PROXYNAME = void 0;
|
|
7
|
+
const helpers_1 = require("../utils/helpers");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
exports.FALLBACK_PROXYNAME = 'sitecore-jss-proxy-app';
|
|
10
|
+
/**
|
|
11
|
+
* Set of CLI prompts for an SXP app
|
|
12
|
+
*/
|
|
13
|
+
exports.proxyPrompts = [
|
|
14
|
+
{
|
|
15
|
+
type: 'input',
|
|
16
|
+
name: 'proxyAppDestination',
|
|
17
|
+
message: 'Where would you like your proxy app created?',
|
|
18
|
+
default: (answers) => {
|
|
19
|
+
// default proxy destination should be under same root as main app
|
|
20
|
+
return (0, helpers_1.getDefaultProxyDestination)(answers.destination, answers.proxyName || exports.FALLBACK_PROXYNAME);
|
|
21
|
+
},
|
|
22
|
+
when: (answers) => {
|
|
23
|
+
if (answers.yes && !answers.proxyAppDestination) {
|
|
24
|
+
answers.proxyAppDestination = (0, helpers_1.getDefaultProxyDestination)(answers.destination, answers.proxyName || exports.FALLBACK_PROXYNAME);
|
|
25
|
+
}
|
|
26
|
+
return !answers.proxyAppDestination;
|
|
27
|
+
},
|
|
28
|
+
validate: (input, answers) => {
|
|
29
|
+
if (path_1.default.resolve(input) === path_1.default.resolve(answers.destination)) {
|
|
30
|
+
return 'Paths for main app and proxy cannot match. Please choose another destination';
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sxpPrompts = void 0;
|
|
4
|
+
const base_1 = require("./base");
|
|
5
|
+
/**
|
|
6
|
+
* Set of CLI prompts for an SXP app
|
|
7
|
+
*/
|
|
8
|
+
exports.sxpPrompts = [
|
|
9
|
+
{
|
|
10
|
+
type: 'input',
|
|
11
|
+
name: 'hostName',
|
|
12
|
+
message: 'What is your Sitecore hostname (used if deployed to Sitecore)?',
|
|
13
|
+
default: (answers) => `${answers.appName || base_1.DEFAULT_APPNAME}.dev.local`,
|
|
14
|
+
when: (answers) => {
|
|
15
|
+
if (answers.yes && !answers.hostName) {
|
|
16
|
+
answers.hostName = `${answers.appName || base_1.DEFAULT_APPNAME}.dev.local`;
|
|
17
|
+
}
|
|
18
|
+
return !answers.hostName;
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: 'list',
|
|
23
|
+
name: 'fetchWith',
|
|
24
|
+
message: 'How would you like to fetch Layout and Dictionary data?',
|
|
25
|
+
choices: Object.values(base_1.FetchWith),
|
|
26
|
+
default: base_1.DEFAULT_FETCHWITH,
|
|
27
|
+
when: (answers) => {
|
|
28
|
+
if (answers.yes && !answers.fetchWith) {
|
|
29
|
+
answers.fetchWith = base_1.DEFAULT_FETCHWITH;
|
|
30
|
+
}
|
|
31
|
+
return !answers.fetchWith;
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
];
|
|
@@ -35,11 +35,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.removeFile = exports.writeFileToPath = exports.getAppPrefix = exports.getBaseTemplates = exports.getAllTemplates = exports.sortKeys = exports.saveConfiguration = exports.
|
|
38
|
+
exports.removeFile = exports.writeFileToPath = exports.getAppPrefix = exports.getBaseTemplates = exports.getAllTemplates = exports.sortKeys = exports.saveConfiguration = exports.writeJsonFile = exports.openJsonFile = exports.getPascalCaseName = exports.isDevEnvironment = exports.getRelativeProxyDestination = exports.getDefaultProxyDestination = exports.proxyAppMatcher = void 0;
|
|
39
39
|
const chalk_1 = __importDefault(require("chalk"));
|
|
40
40
|
const fs_1 = __importDefault(require("fs"));
|
|
41
41
|
const path_1 = __importStar(require("path"));
|
|
42
42
|
const InitializerFactory_1 = require("../../InitializerFactory");
|
|
43
|
+
// matched for proxy templates
|
|
44
|
+
exports.proxyAppMatcher = /node-headless.+|node-xmcloud.+/g;
|
|
45
|
+
/**
|
|
46
|
+
* Returns the default path for proxy app initialized alongside main JSS tempalates.
|
|
47
|
+
* @param {string} mainAppDestination target destination for main app
|
|
48
|
+
* @param {string} proxyName name of for the proxy app folder
|
|
49
|
+
* @returns {string} target path for proxy app
|
|
50
|
+
*/
|
|
51
|
+
const getDefaultProxyDestination = (mainAppDestination, proxyName) => path_1.default.join(mainAppDestination, '..', proxyName);
|
|
52
|
+
exports.getDefaultProxyDestination = getDefaultProxyDestination;
|
|
53
|
+
const getRelativeProxyDestination = (mainDestination, proxyDestination) => `${path_1.default.relative(path_1.default.resolve(mainDestination), path_1.default.resolve(proxyDestination))}${path_1.sep}`;
|
|
54
|
+
exports.getRelativeProxyDestination = getRelativeProxyDestination;
|
|
43
55
|
/**
|
|
44
56
|
* Determines whether you are in a dev environment.
|
|
45
57
|
* It's `true` if you are inside the monorepo
|
|
@@ -61,46 +73,44 @@ const getPascalCaseName = (name) => {
|
|
|
61
73
|
};
|
|
62
74
|
exports.getPascalCaseName = getPascalCaseName;
|
|
63
75
|
/**
|
|
64
|
-
* Provides
|
|
65
|
-
* @param {string}
|
|
66
|
-
* @returns
|
|
76
|
+
* Provides json data from a file
|
|
77
|
+
* @param {string} jsonFilePath path to the .json file.
|
|
78
|
+
* @returns json data
|
|
67
79
|
*/
|
|
68
|
-
const
|
|
69
|
-
const filePath = path_1.default.resolve(pkgPath !== null && pkgPath !== void 0 ? pkgPath : `.${path_1.sep}package.json`);
|
|
80
|
+
const openJsonFile = (jsonFilePath) => {
|
|
70
81
|
try {
|
|
71
|
-
const data = fs_1.default.readFileSync(
|
|
82
|
+
const data = fs_1.default.readFileSync(jsonFilePath, 'utf8');
|
|
72
83
|
return data ? JSON.parse(data) : undefined;
|
|
73
84
|
}
|
|
74
85
|
catch (error) {
|
|
75
|
-
console.log(chalk_1.default.red(`The following error occurred while trying to read ${
|
|
86
|
+
console.log(chalk_1.default.red(`The following error occurred while trying to read ${jsonFilePath}:`));
|
|
76
87
|
console.log(chalk_1.default.red(error));
|
|
77
88
|
}
|
|
78
89
|
};
|
|
79
|
-
exports.
|
|
90
|
+
exports.openJsonFile = openJsonFile;
|
|
80
91
|
/**
|
|
81
|
-
* Creates
|
|
82
|
-
* @param {Object} data data to be written into
|
|
83
|
-
* @param {string}
|
|
92
|
+
* Creates a .json file and inserts provided data
|
|
93
|
+
* @param {Object} data data to be written into the .json file
|
|
94
|
+
* @param {string} jsonFilePath a path to a file.
|
|
84
95
|
*/
|
|
85
|
-
const
|
|
86
|
-
const filePath = path_1.default.resolve(pkgPath !== null && pkgPath !== void 0 ? pkgPath : `.${path_1.sep}package.json`);
|
|
96
|
+
const writeJsonFile = (data, jsonFilePath) => {
|
|
87
97
|
try {
|
|
88
|
-
fs_1.default.writeFileSync(
|
|
98
|
+
fs_1.default.writeFileSync(jsonFilePath, JSON.stringify(data, null, 2), { encoding: 'utf8' });
|
|
89
99
|
}
|
|
90
100
|
catch (error) {
|
|
91
|
-
console.log(chalk_1.default.red(`The following error occurred while trying to write ${
|
|
101
|
+
console.log(chalk_1.default.red(`The following error occurred while trying to write ${jsonFilePath}:`));
|
|
92
102
|
console.log(chalk_1.default.red(error));
|
|
93
103
|
}
|
|
94
104
|
};
|
|
95
|
-
exports.
|
|
105
|
+
exports.writeJsonFile = writeJsonFile;
|
|
96
106
|
/**
|
|
97
107
|
* Save configuration params to the package.json
|
|
98
108
|
* @param {string[]} templates templates applied to the sample
|
|
99
109
|
* @param {string} [pkgPath] path to the package.json
|
|
100
110
|
*/
|
|
101
111
|
const saveConfiguration = (templates, pkgPath) => {
|
|
102
|
-
const pkg = (0, exports.
|
|
103
|
-
(0, exports.
|
|
112
|
+
const pkg = (0, exports.openJsonFile)(pkgPath);
|
|
113
|
+
(0, exports.writeJsonFile)(Object.assign(Object.assign({}, pkg), { config: Object.assign(Object.assign({}, pkg.config), { templates }) }), pkgPath);
|
|
104
114
|
};
|
|
105
115
|
exports.saveConfiguration = saveConfiguration;
|
|
106
116
|
const sortKeys = (obj) => {
|
package/dist/init-runner.js
CHANGED
|
@@ -42,7 +42,7 @@ const common_1 = require("./common");
|
|
|
42
42
|
const InitializerFactory_1 = require("./InitializerFactory");
|
|
43
43
|
const initRunner = (initializers, args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
44
|
let nextStepsArr = [];
|
|
45
|
-
|
|
45
|
+
const appNames = new Set([]);
|
|
46
46
|
const initFactory = new InitializerFactory_1.InitializerFactory();
|
|
47
47
|
const runner = (inits) => __awaiter(void 0, void 0, void 0, function* () {
|
|
48
48
|
var _a;
|
|
@@ -53,7 +53,10 @@ const initRunner = (initializers, args) => __awaiter(void 0, void 0, void 0, fun
|
|
|
53
53
|
}
|
|
54
54
|
args.silent || console.log(chalk_1.default.cyan(`Initializing '${init}'...`));
|
|
55
55
|
const response = yield initializer.init(args);
|
|
56
|
-
|
|
56
|
+
// We can have multiple appNames if base template requires to setup an additional standalone app (e.g. XM Cloud proxy)
|
|
57
|
+
if (initializer.isBase) {
|
|
58
|
+
appNames.add(response.appName);
|
|
59
|
+
}
|
|
57
60
|
nextStepsArr = [...nextStepsArr, ...((_a = response.nextSteps) !== null && _a !== void 0 ? _a : [])];
|
|
58
61
|
// process any returned initializers
|
|
59
62
|
if (response.initializers && response.initializers.length > 0) {
|
|
@@ -81,7 +84,7 @@ const initRunner = (initializers, args) => __awaiter(void 0, void 0, void 0, fun
|
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
if (!args.silent) {
|
|
84
|
-
(0, common_1.nextSteps)(
|
|
87
|
+
(0, common_1.nextSteps)([...appNames], nextStepsArr);
|
|
85
88
|
}
|
|
86
89
|
});
|
|
87
90
|
exports.initRunner = initRunner;
|
|
@@ -32,9 +32,6 @@ class AngularInitializer {
|
|
|
32
32
|
if (!args.templates.includes('angular-xmcloud')) {
|
|
33
33
|
addInitializers.push('angular-xmcloud');
|
|
34
34
|
}
|
|
35
|
-
if (!args.templates.includes('node-xmcloud-proxy')) {
|
|
36
|
-
addInitializers.push('node-xmcloud-proxy');
|
|
37
|
-
}
|
|
38
35
|
}
|
|
39
36
|
else {
|
|
40
37
|
// invoke default non-XMC init
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.prompts = void 0;
|
|
4
4
|
const common_1 = require("../../common");
|
|
5
5
|
exports.prompts = [
|
|
6
|
-
|
|
6
|
+
// XMCloud answer defines init behavior. Prompt must go first
|
|
7
7
|
{
|
|
8
8
|
type: 'confirm',
|
|
9
9
|
name: 'xmcloud',
|
|
@@ -11,16 +11,16 @@ exports.prompts = [
|
|
|
11
11
|
default: false,
|
|
12
12
|
when: (answers) => {
|
|
13
13
|
// don't prompt if --yes or angular-xmcloud template was specified
|
|
14
|
-
if (answers.
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
else if (answers.templates.includes('angular-xmcloud') &&
|
|
14
|
+
if (answers.templates.includes('angular-xmcloud') &&
|
|
18
15
|
!answers.templates.includes('angular-sxp')) {
|
|
19
16
|
answers.xmcloud = true;
|
|
20
17
|
return false;
|
|
21
18
|
}
|
|
19
|
+
if (answers.yes) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
22
|
return true;
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
|
-
...common_1.
|
|
25
|
+
...common_1.clientAppPrompts,
|
|
26
26
|
];
|
|
@@ -31,9 +31,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
34
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
38
|
const path_1 = __importStar(require("path"));
|
|
36
39
|
const common_1 = require("../../common");
|
|
40
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
37
41
|
class AngularSxpInitializer {
|
|
38
42
|
get isBase() {
|
|
39
43
|
return false;
|
|
@@ -41,8 +45,10 @@ class AngularSxpInitializer {
|
|
|
41
45
|
init(args) {
|
|
42
46
|
var _a, _b;
|
|
43
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
const pkg = (0, common_1.
|
|
45
|
-
const
|
|
48
|
+
const pkg = (0, common_1.openJsonFile)(`${args.destination}${path_1.sep}package.json`);
|
|
49
|
+
const answers = yield inquirer_1.default.prompt(common_1.sxpPrompts, args);
|
|
50
|
+
const styleguideAnswers = yield inquirer_1.default.prompt(common_1.styleguidePrompts, args);
|
|
51
|
+
const mergedArgs = Object.assign(Object.assign(Object.assign(Object.assign({}, args), { appName: args.appName || ((_a = pkg === null || pkg === void 0 ? void 0 : pkg.config) === null || _a === void 0 ? void 0 : _a.appName) || common_1.DEFAULT_APPNAME, appPrefix: args.appPrefix || ((_b = pkg === null || pkg === void 0 ? void 0 : pkg.config) === null || _b === void 0 ? void 0 : _b.prefix) || false }), answers), styleguideAnswers);
|
|
46
52
|
const templatePath = path_1.default.resolve(__dirname, '../../templates/angular-sxp');
|
|
47
53
|
yield (0, common_1.transform)(templatePath, mergedArgs);
|
|
48
54
|
const response = {
|
|
@@ -31,23 +31,47 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
34
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
38
|
const path_1 = __importStar(require("path"));
|
|
36
39
|
const common_1 = require("../../common");
|
|
40
|
+
const proxy_1 = require("../../common/prompts/proxy");
|
|
41
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
42
|
+
const helpers_1 = require("../../common/utils/helpers");
|
|
37
43
|
class AngularXmCloudInitializer {
|
|
38
44
|
get isBase() {
|
|
39
45
|
return false;
|
|
40
46
|
}
|
|
41
47
|
init(args) {
|
|
42
|
-
var _a, _b;
|
|
48
|
+
var _a, _b, _c, _d;
|
|
43
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
const pkg = (0, common_1.
|
|
45
|
-
const
|
|
50
|
+
const pkg = (0, common_1.openJsonFile)(`${args.destination}${path_1.sep}package.json`);
|
|
51
|
+
const addInitializers = [];
|
|
52
|
+
// angular-xmcloud requires node-xmcloud-proxy
|
|
53
|
+
if (!args.templates.includes('node-xmcloud-proxy')) {
|
|
54
|
+
addInitializers.push('node-xmcloud-proxy');
|
|
55
|
+
}
|
|
56
|
+
// ensure args.proxyAppDestination is populated
|
|
57
|
+
const promptArgs = {
|
|
58
|
+
yes: args.yes,
|
|
59
|
+
destination: args.destination,
|
|
60
|
+
proxyName: 'node-xmcloud-proxy',
|
|
61
|
+
proxyAppDestination: args.proxyAppDestination,
|
|
62
|
+
};
|
|
63
|
+
const proxyDetails = yield inquirer_1.default.prompt(proxy_1.proxyPrompts, promptArgs);
|
|
64
|
+
args.proxyAppDestination = proxyDetails.proxyAppDestination;
|
|
65
|
+
const finalArgs = Object.assign(Object.assign(Object.assign(Object.assign({}, args), { appName: args.appName || ((_a = pkg === null || pkg === void 0 ? void 0 : pkg.config) === null || _a === void 0 ? void 0 : _a.appName) || common_1.DEFAULT_APPNAME, appPrefix: args.appPrefix || ((_b = pkg === null || pkg === void 0 ? void 0 : pkg.config) === null || _b === void 0 ? void 0 : _b.prefix) || false }), proxyDetails), { relativeProxyAppDestination: (0, helpers_1.getRelativeProxyDestination)(args.destination, args.proxyAppDestination) });
|
|
46
66
|
const templatePath = path_1.default.resolve(__dirname, '../../templates/angular-xmcloud');
|
|
47
|
-
yield (0, common_1.transform)(templatePath,
|
|
67
|
+
yield (0, common_1.transform)(templatePath, finalArgs);
|
|
68
|
+
if (args.templates.includes('angular-sxp') || ((_d = (_c = pkg.config) === null || _c === void 0 ? void 0 : _c.templates) === null || _d === void 0 ? void 0 : _d.includes('angular-sxp'))) {
|
|
69
|
+
console.log((0, common_1.incompatibleAddonsMsg)('angular-xmcloud', 'angular-sxp'));
|
|
70
|
+
}
|
|
48
71
|
const response = {
|
|
49
72
|
nextSteps: [],
|
|
50
73
|
appName: args.appName || common_1.DEFAULT_APPNAME,
|
|
74
|
+
initializers: addInitializers,
|
|
51
75
|
};
|
|
52
76
|
return response;
|
|
53
77
|
});
|
|
@@ -105,9 +105,9 @@ class NextjsInitializer {
|
|
|
105
105
|
}
|
|
106
106
|
if (!addInitializers.includes('nextjs-styleguide') &&
|
|
107
107
|
!args.templates.includes('nextjs-styleguide')) {
|
|
108
|
-
const pkg = (0, common_1.
|
|
108
|
+
const pkg = (0, common_1.openJsonFile)(pkgPath);
|
|
109
109
|
pkg.scripts.bootstrap = pkg.scripts.bootstrap.replace(' && graphql-let', '');
|
|
110
|
-
(0, common_1.
|
|
110
|
+
(0, common_1.writeJsonFile)(pkg, pkgPath);
|
|
111
111
|
}
|
|
112
112
|
const response = {
|
|
113
113
|
nextSteps: [`* Connect to Sitecore with ${chalk_1.default.green('jss setup')} (optional)`],
|
|
@@ -12,8 +12,10 @@ var Prerender;
|
|
|
12
12
|
Prerender["SSR"] = "SSR";
|
|
13
13
|
})(Prerender = exports.Prerender || (exports.Prerender = {}));
|
|
14
14
|
const DEFAULT_PRERENDER = Prerender.SSG;
|
|
15
|
+
// still need sxp prompts here until sitecore/config is no longer added to xmc app
|
|
15
16
|
exports.prompts = [
|
|
16
17
|
...common_1.clientAppPrompts,
|
|
18
|
+
...common_1.sxpPrompts,
|
|
17
19
|
{
|
|
18
20
|
type: 'list',
|
|
19
21
|
name: 'prerender',
|
|
@@ -10,10 +10,10 @@ const common_1 = require("../../common");
|
|
|
10
10
|
const removeDevDependencies = (projectPath) => {
|
|
11
11
|
// remove `next-transpile-modules` dependency
|
|
12
12
|
const packagePath = path_1.default.join(projectPath, 'package.json');
|
|
13
|
-
const pkg = (0, common_1.
|
|
13
|
+
const pkg = (0, common_1.openJsonFile)(packagePath);
|
|
14
14
|
if (pkg === null || pkg === void 0 ? void 0 : pkg.devDependencies['next-transpile-modules']) {
|
|
15
15
|
delete pkg.devDependencies['next-transpile-modules'];
|
|
16
|
-
(0, common_1.
|
|
16
|
+
(0, common_1.writeJsonFile)(pkg, packagePath);
|
|
17
17
|
}
|
|
18
18
|
// remove monorepo next.config.js plugin
|
|
19
19
|
const monorepoPlugin = path_1.default.join(projectPath, 'src/lib/next-config/plugins/monorepo.js');
|
|
@@ -41,7 +41,7 @@ class NextjsMultisiteInitializer {
|
|
|
41
41
|
init(args) {
|
|
42
42
|
var _a, _b;
|
|
43
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
const pkg = (0, common_1.
|
|
44
|
+
const pkg = (0, common_1.openJsonFile)(`${args.destination}${path_1.sep}package.json`);
|
|
45
45
|
const mergedArgs = Object.assign(Object.assign({}, args), { appName: args.appName || ((_a = pkg === null || pkg === void 0 ? void 0 : pkg.config) === null || _a === void 0 ? void 0 : _a.appName) || common_1.DEFAULT_APPNAME, appPrefix: args.appPrefix || ((_b = pkg === null || pkg === void 0 ? void 0 : pkg.config) === null || _b === void 0 ? void 0 : _b.prefix) || false });
|
|
46
46
|
const templatePath = path_1.default.resolve(__dirname, '../../templates/nextjs-multisite');
|
|
47
47
|
yield (0, common_1.transform)(templatePath, mergedArgs);
|
|
@@ -46,7 +46,7 @@ class NextjsStyleguideInitializer {
|
|
|
46
46
|
init(args) {
|
|
47
47
|
var _a, _b;
|
|
48
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
const pkg = (0, common_1.
|
|
49
|
+
const pkg = (0, common_1.openJsonFile)(`${args.destination}${path_1.sep}package.json`);
|
|
50
50
|
const answers = yield inquirer_1.default.prompt(common_1.styleguidePrompts, args);
|
|
51
51
|
const mergedArgs = Object.assign(Object.assign(Object.assign({}, args), { appName: args.appName || ((_a = pkg === null || pkg === void 0 ? void 0 : pkg.config) === null || _a === void 0 ? void 0 : _a.appName) || common_1.DEFAULT_APPNAME, appPrefix: args.appPrefix || ((_b = pkg === null || pkg === void 0 ? void 0 : pkg.config) === null || _b === void 0 ? void 0 : _b.prefix) || false }), answers);
|
|
52
52
|
const templatePath = path_1.default.resolve(__dirname, '../../templates/nextjs-styleguide');
|