Skip to content

Commit 49268ec

Browse files
committed
feat: create simple angular skeleton
1 parent 6084706 commit 49268ec

17 files changed

Lines changed: 394 additions & 325 deletions

File tree

.editorconfig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ root = true
33

44
[*]
55
charset = utf-8
6-
end_of_line = lf
7-
indent_size = 2
86
indent_style = space
7+
indent_size = 2
98
insert_final_newline = true
10-
max_line_length = 140
119
trim_trailing_whitespace = true
10+
end_of_line = lf
11+
max_line_length = 140
1212

1313
[*.md]
14-
indent_size = 4
14+
max_line_length = off
1515

1616
[*.ts]
1717
quote_type = single

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"author": "Marcel Hendrich",
33
"bin": {
4-
"swagstack": "dist/cli/index.js"
4+
"swagstack": "dist/index.js"
55
},
66
"contributors": [
77
{
@@ -11,10 +11,10 @@
1111
],
1212
"dependencies": {
1313
"@inquirer/prompts": "8.3.2",
14-
"commander": "14.0.3",
1514
"chalk": "5.6.2",
16-
"figlet": "1.11.0",
15+
"commander": "14.0.3",
1716
"execa": "9.6.1",
17+
"figlet": "1.11.0",
1818
"fs-extra": "11.3.4",
1919
"handlebars": "4.7.9"
2020
},
@@ -35,9 +35,9 @@
3535
"private": true,
3636
"repository": "https://github.com/inpercima/swagstack",
3737
"scripts": {
38-
"build": "tsc",
39-
"dev": "tsx src/cli/index.ts",
40-
"start": "node dist/cli/index.js"
38+
"build": "tsc && node scripts/copy-templates.js",
39+
"dev": "tsx src/index.ts",
40+
"start": "node dist/index.js"
4141
},
4242
"type": "module",
4343
"version": "3.0.0-SNAPSHOT"

scripts/copy-templates.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import fs from 'fs-extra';
2+
import path from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
5+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
6+
7+
const source = path.resolve(__dirname, '../src/templates');
8+
const target = path.resolve(__dirname, '../dist/templates');
9+
10+
await fs.ensureDir(path.dirname(target));
11+
await fs.copy(source, target, { overwrite: true });
12+
13+
console.log(`Copied templates: ${source} -> ${target}`);

src/commands/init.ts

Lines changed: 0 additions & 214 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import path from 'node:path';
2+
import { PRESETS, WorkOptions } from '../../../utils/types.js';
3+
import { run } from '../../../utils/utils.js';
4+
import { ANGULAR_CLI_VERSION } from '../../../utils/versions.js';
5+
6+
export async function createAngularFrontendSkeleton(config: WorkOptions): Promise<void> {
7+
const isAngularOnly = config.preset === PRESETS.ANGULAR_ONLY;
8+
const workingRootDir = isAngularOnly ? process.cwd() : config.repoRoot;
9+
const workingAngularDir = isAngularOnly
10+
? config.repoRoot
11+
: path.join(config.repoRoot, 'frontend');
12+
await run(
13+
'npx',
14+
[
15+
'-y',
16+
`@angular/cli@${ANGULAR_CLI_VERSION}`,
17+
'new',
18+
isAngularOnly ? config.projectName : 'frontend',
19+
'--interactive=false',
20+
'--skip-git',
21+
'--style=css',
22+
'--routing',
23+
'--package-manager',
24+
config.pm,
25+
],
26+
workingRootDir,
27+
);
28+
29+
await run('ng', ['add', `angular-eslint`], workingAngularDir);
30+
31+
if (config.useCypress) {
32+
await run('ng', ['add', `@cypress/schematic`], workingAngularDir);
33+
}
34+
35+
if (config.useAngularMaterial) {
36+
await run('ng', ['add', `@angular/material`], workingAngularDir);
37+
}
38+
}

0 commit comments

Comments
 (0)