@mrktg-common/project-generator 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/args.js +1 -1
- package/src/questions.js +3 -0
- package/template/base/astro.config.mjs +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrktg-common/project-generator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Движок генератора лендингов: вопросы, шаблон Astro, подстановка. Бренды, регионы и региональные оверлеи приходят от региональных генераторов.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
package/src/args.js
CHANGED
|
@@ -45,7 +45,7 @@ export const buildHelp = ({ command, registry, landingPrefix = defaultLandingPre
|
|
|
45
45
|
npm create ${command.replace(/(^|\/)create-/, '$1')} [имя-проекта | .] [-- флаги]
|
|
46
46
|
|
|
47
47
|
Флаги (каждый заменяет соответствующий вопрос):
|
|
48
|
-
--brand <id>
|
|
48
|
+
--brand <id> бренд, подходит и прежнее написание id: ${registry.brands.map((brand) => `${brand.id} (${brand.title.en})`).join(', ')}
|
|
49
49
|
--path <slug> путь лендинга после префикса бренда; прод-урл:
|
|
50
50
|
${registry.brands.map((brand) => ` ${brand.id}: https://${brand.siteHost}/${landingPrefix(brand)}/<slug>/`).join('\n')}
|
|
51
51
|
--fluid / --no-fluid флюидная вёрстка (clamp-scaling); по умолчанию нет
|
package/src/questions.js
CHANGED
|
@@ -52,6 +52,8 @@ export const buildQuestions = ({ registry, landingPrefix = defaultLandingPrefix
|
|
|
52
52
|
message: 'WHITE_LABEL — под какой бренд лендинг?',
|
|
53
53
|
options: registry.brands.map((brand) => ({ value: brand.id, label: brand.title.en })),
|
|
54
54
|
}),
|
|
55
|
+
// во флаге можно прежнее написание id: alias'ы реестра приводят его к каноническому
|
|
56
|
+
normalize: (value) => registry.resolveBrand(value)?.id ?? value,
|
|
55
57
|
validate: (value) => (registry.isBrandId(value) ? undefined : `Неизвестный бренд «${value}». Есть: ${registry.brandIds.join(', ')}`),
|
|
56
58
|
},
|
|
57
59
|
{
|
|
@@ -102,6 +104,7 @@ export const askQuestions = async (config, initial) => {
|
|
|
102
104
|
for (const question of buildQuestions(config)) {
|
|
103
105
|
if (question.when && !question.when(ctx)) continue;
|
|
104
106
|
if (ctx[question.id] !== undefined) {
|
|
107
|
+
if (question.normalize) ctx[question.id] = question.normalize(ctx[question.id]);
|
|
105
108
|
const error = question.validate?.(ctx[question.id]);
|
|
106
109
|
if (error) throw new Error(`--${question.id}: ${error}`);
|
|
107
110
|
continue;
|
|
@@ -10,8 +10,8 @@ export default defineConfig({
|
|
|
10
10
|
base: "{{BASE_PATH}}",
|
|
11
11
|
build: {
|
|
12
12
|
format: "directory",
|
|
13
|
-
//
|
|
14
|
-
|
|
13
|
+
// Без assetsPrefix: пути к ассетам от корня сайта (<base>/_astro/…). Относительные ./_astro/… ломаются,
|
|
14
|
+
// когда админка отдаёт страницу без слеша на конце, — браузер резолвит их от родительской папки.
|
|
15
15
|
},
|
|
16
16
|
integrations: [react()],
|
|
17
17
|
vite: {
|