create-analog 1.4.0 → 1.5.0-beta.10
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/index.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
import { green, red, reset, yellow } from 'kolorist';
|
|
5
5
|
import minimist from 'minimist';
|
|
6
6
|
import { execSync } from 'node:child_process';
|
|
7
|
-
import fs from 'node:fs';
|
|
8
|
-
import path from 'node:path';
|
|
7
|
+
import fs, { readdirSync } from 'node:fs';
|
|
8
|
+
import path, { join } from 'node:path';
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
10
10
|
import prompts from 'prompts';
|
|
11
11
|
|
|
@@ -32,6 +32,25 @@ const APPS = [
|
|
|
32
32
|
],
|
|
33
33
|
},
|
|
34
34
|
];
|
|
35
|
+
const HIGHLIGHTERS = {
|
|
36
|
+
prismjs: {
|
|
37
|
+
highlighter: 'withPrismHighlighter',
|
|
38
|
+
entryPoint: 'prism-highlighter',
|
|
39
|
+
dependencies: {
|
|
40
|
+
'marked-highlight': '^2.0.1',
|
|
41
|
+
prismjs: '^1.29.0',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
shiki: {
|
|
45
|
+
highlighter: 'withShikiHighlighter',
|
|
46
|
+
entryPoint: 'shiki-highlighter',
|
|
47
|
+
dependencies: {
|
|
48
|
+
marked: '^7.0.0',
|
|
49
|
+
'marked-shiki': '^1.1.0',
|
|
50
|
+
shiki: '^1.6.1',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
35
54
|
|
|
36
55
|
const renameFiles = {
|
|
37
56
|
_gitignore: '.gitignore',
|
|
@@ -100,6 +119,16 @@ async function init() {
|
|
|
100
119
|
};
|
|
101
120
|
}),
|
|
102
121
|
},
|
|
122
|
+
{
|
|
123
|
+
type: (prev) => (prev === 'blog' ? 'select' : null),
|
|
124
|
+
name: 'syntaxHighlighter',
|
|
125
|
+
message: reset('Choose a syntax highlighter:'),
|
|
126
|
+
choices: Object.keys(HIGHLIGHTERS).map((highlighter) => ({
|
|
127
|
+
title: highlighter,
|
|
128
|
+
value: highlighter,
|
|
129
|
+
})),
|
|
130
|
+
initial: 1,
|
|
131
|
+
},
|
|
103
132
|
{
|
|
104
133
|
type: skipTailwind ? null : 'confirm',
|
|
105
134
|
name: 'tailwind',
|
|
@@ -118,7 +147,14 @@ async function init() {
|
|
|
118
147
|
}
|
|
119
148
|
|
|
120
149
|
// user choice associated with prompts
|
|
121
|
-
const {
|
|
150
|
+
const {
|
|
151
|
+
framework,
|
|
152
|
+
overwrite,
|
|
153
|
+
packageName,
|
|
154
|
+
variant,
|
|
155
|
+
tailwind,
|
|
156
|
+
syntaxHighlighter,
|
|
157
|
+
} = result;
|
|
122
158
|
|
|
123
159
|
const root = path.join(cwd, targetDir);
|
|
124
160
|
|
|
@@ -130,6 +166,9 @@ async function init() {
|
|
|
130
166
|
|
|
131
167
|
// determine template
|
|
132
168
|
template = variant || framework || template;
|
|
169
|
+
// determine syntax highlighter
|
|
170
|
+
let highlighter =
|
|
171
|
+
syntaxHighlighter ?? (template === 'blog' ? 'prismjs' : null);
|
|
133
172
|
skipTailwind = !tailwind || skipTailwind;
|
|
134
173
|
|
|
135
174
|
console.log(`\nScaffolding project in ${root}...`);
|
|
@@ -146,6 +185,7 @@ async function init() {
|
|
|
146
185
|
const targetPath = renameFiles[file]
|
|
147
186
|
? path.join(root, renameFiles[file])
|
|
148
187
|
: path.join(root, file);
|
|
188
|
+
|
|
149
189
|
if (content) {
|
|
150
190
|
fs.writeFileSync(targetPath, content);
|
|
151
191
|
} else {
|
|
@@ -173,9 +213,14 @@ async function init() {
|
|
|
173
213
|
pkg.name = packageName || getProjectName();
|
|
174
214
|
pkg.scripts.start = getStartCommand(pkgManager);
|
|
175
215
|
|
|
216
|
+
if (template === 'blog' && highlighter) {
|
|
217
|
+
ensureSyntaxHighlighter(root, pkg, highlighter);
|
|
218
|
+
}
|
|
219
|
+
|
|
176
220
|
if (!skipTailwind) addTailwindDevDependencies(pkg);
|
|
177
|
-
if (pkgManager === 'yarn'
|
|
178
|
-
addYarnDevDependencies(pkg);
|
|
221
|
+
if (pkgManager === 'yarn') {
|
|
222
|
+
addYarnDevDependencies(pkg, template);
|
|
223
|
+
}
|
|
179
224
|
|
|
180
225
|
write('package.json', JSON.stringify(pkg, null, 2));
|
|
181
226
|
|
|
@@ -327,8 +372,36 @@ function addTailwindDevDependencies(pkg) {
|
|
|
327
372
|
);
|
|
328
373
|
}
|
|
329
374
|
|
|
330
|
-
function addYarnDevDependencies(pkg) {
|
|
331
|
-
|
|
375
|
+
function addYarnDevDependencies(pkg, template) {
|
|
376
|
+
// v18
|
|
377
|
+
if (template === 'latest' || template === 'blog') {
|
|
378
|
+
pkg.devDependencies['@nx/angular'] = ['^19.1.0'];
|
|
379
|
+
pkg.devDependencies['@nx/devkit'] = ['^19.1.0'];
|
|
380
|
+
pkg.devDependencies['@nx/vite'] = ['^19.1.0'];
|
|
381
|
+
pkg.devDependencies['nx'] = ['^19.1.0'];
|
|
382
|
+
} else if (template === 'angular-v17') {
|
|
383
|
+
pkg.devDependencies['@angular-devkit/build-angular'] = ['^17.3.5'];
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function ensureSyntaxHighlighter(root, pkg, highlighter) {
|
|
388
|
+
const appConfigPath = path.join(root, 'src/app/app.config.ts');
|
|
389
|
+
const appConfigContent = fs.readFileSync(appConfigPath, 'utf-8');
|
|
390
|
+
|
|
391
|
+
fs.writeFileSync(
|
|
392
|
+
appConfigPath,
|
|
393
|
+
appConfigContent
|
|
394
|
+
.replace(/__HIGHLIGHTER__/g, HIGHLIGHTERS[highlighter].highlighter)
|
|
395
|
+
.replace(
|
|
396
|
+
/__HIGHLIGHTER_ENTRY_POINT__/g,
|
|
397
|
+
HIGHLIGHTERS[highlighter].entryPoint
|
|
398
|
+
)
|
|
399
|
+
);
|
|
400
|
+
|
|
401
|
+
const dependencies = HIGHLIGHTERS[highlighter].dependencies;
|
|
402
|
+
for (const [name, version] of Object.entries(dependencies)) {
|
|
403
|
+
pkg.dependencies[name] = version;
|
|
404
|
+
}
|
|
332
405
|
}
|
|
333
406
|
|
|
334
407
|
init().catch((e) => {
|
package/package.json
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"test": "ng test"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@analogjs/content": "^1.
|
|
19
|
-
"@analogjs/router": "^1.
|
|
18
|
+
"@analogjs/content": "^1.5.0-beta.10",
|
|
19
|
+
"@analogjs/router": "^1.5.0-beta.10",
|
|
20
20
|
"@angular/animations": "^17.2.0",
|
|
21
21
|
"@angular/common": "^17.2.0",
|
|
22
22
|
"@angular/compiler": "^17.2.0",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"zone.js": "~0.14.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@analogjs/platform": "^1.
|
|
42
|
-
"@analogjs/vite-plugin-angular": "^1.
|
|
41
|
+
"@analogjs/platform": "^1.5.0-beta.10",
|
|
42
|
+
"@analogjs/vite-plugin-angular": "^1.5.0-beta.10",
|
|
43
43
|
"@angular/cli": "^17.2.0",
|
|
44
44
|
"@angular/compiler-cli": "^17.2.0",
|
|
45
45
|
"@nx/vite": "~18.0.0",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"test": "ng test"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@analogjs/content": "^1.
|
|
19
|
-
"@analogjs/router": "^1.
|
|
18
|
+
"@analogjs/content": "^1.5.0-beta.10",
|
|
19
|
+
"@analogjs/router": "^1.5.0-beta.10",
|
|
20
20
|
"@angular/animations": "^18.0.0",
|
|
21
21
|
"@angular/common": "^18.0.0",
|
|
22
22
|
"@angular/compiler": "^18.0.0",
|
|
@@ -29,16 +29,14 @@
|
|
|
29
29
|
"front-matter": "^4.0.2",
|
|
30
30
|
"marked": "^5.0.2",
|
|
31
31
|
"marked-gfm-heading-id": "^3.1.0",
|
|
32
|
-
"marked-
|
|
33
|
-
"mermaid": "^10.2.4",
|
|
34
|
-
"prismjs": "^1.29.0",
|
|
32
|
+
"marked-mangle": "^1.1.7",
|
|
35
33
|
"rxjs": "~7.5.6",
|
|
36
34
|
"tslib": "^2.4.0",
|
|
37
35
|
"zone.js": "~0.14.0"
|
|
38
36
|
},
|
|
39
37
|
"devDependencies": {
|
|
40
|
-
"@analogjs/platform": "^1.
|
|
41
|
-
"@analogjs/vite-plugin-angular": "^1.
|
|
38
|
+
"@analogjs/platform": "^1.5.0-beta.10",
|
|
39
|
+
"@analogjs/vite-plugin-angular": "^1.5.0-beta.10",
|
|
42
40
|
"@angular-devkit/build-angular": "^18.0.0",
|
|
43
41
|
"@angular/cli": "^18.0.0",
|
|
44
42
|
"@angular/compiler-cli": "^18.0.0",
|
|
@@ -3,6 +3,7 @@ import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
|
|
|
3
3
|
import { provideClientHydration } from '@angular/platform-browser';
|
|
4
4
|
import { provideFileRouter } from '@analogjs/router';
|
|
5
5
|
import { provideContent, withMarkdownRenderer } from '@analogjs/content';
|
|
6
|
+
import { __HIGHLIGHTER__ } from '@analogjs/content/__HIGHLIGHTER_ENTRY_POINT__';
|
|
6
7
|
|
|
7
8
|
export const appConfig: ApplicationConfig = {
|
|
8
9
|
providers: [
|
|
@@ -10,6 +11,6 @@ export const appConfig: ApplicationConfig = {
|
|
|
10
11
|
provideFileRouter(),
|
|
11
12
|
provideHttpClient(withFetch()),
|
|
12
13
|
provideClientHydration(),
|
|
13
|
-
provideContent(withMarkdownRenderer()),
|
|
14
|
+
provideContent(withMarkdownRenderer(), __HIGHLIGHTER__()),
|
|
14
15
|
],
|
|
15
16
|
};
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
},
|
|
16
16
|
"private": true,
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@analogjs/content": "^1.
|
|
19
|
-
"@analogjs/router": "^1.
|
|
18
|
+
"@analogjs/content": "^1.5.0-beta.10",
|
|
19
|
+
"@analogjs/router": "^1.5.0-beta.10",
|
|
20
20
|
"@angular/animations": "^18.0.0",
|
|
21
21
|
"@angular/common": "^18.0.0",
|
|
22
22
|
"@angular/compiler": "^18.0.0",
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"marked": "^5.0.2",
|
|
31
31
|
"marked-gfm-heading-id": "^3.1.0",
|
|
32
32
|
"marked-highlight": "^2.0.1",
|
|
33
|
-
"
|
|
33
|
+
"marked-mangle": "^1.1.7",
|
|
34
34
|
"prismjs": "^1.29.0",
|
|
35
35
|
"rxjs": "~7.8.0",
|
|
36
36
|
"tslib": "^2.3.0",
|
|
37
37
|
"zone.js": "~0.14.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@analogjs/platform": "^1.
|
|
41
|
-
"@analogjs/vite-plugin-angular": "^1.
|
|
40
|
+
"@analogjs/platform": "^1.5.0-beta.10",
|
|
41
|
+
"@analogjs/vite-plugin-angular": "^1.5.0-beta.10",
|
|
42
42
|
"@angular-devkit/build-angular": "^18.0.0",
|
|
43
43
|
"@angular/cli": "^18.0.0",
|
|
44
44
|
"@angular/compiler-cli": "^18.0.0",
|