-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-version.ts
More file actions
57 lines (51 loc) · 1.69 KB
/
generate-version.ts
File metadata and controls
57 lines (51 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import * as rimraf from "rimraf";
import { execSync, ExecSyncOptions } from "child_process";
const projectName = "the-project";
const applicationName = "the-application";
const libraryName = "the-library";
const version = process.argv[2];
const flags = new Set(process.argv.slice(3));
const branch = version + Array.from(flags).sort().join("");
console.log("generating", branch);
execSync(`git checkout -b ${branch}`);
rimraf.sync(projectName);
runAndCommit(`yarn add -D @angular/cli@${version}`);
runAndCommit(
`npx ng new ${projectName} --createApplication=${!flags.has(
"-noApp"
)} --routing=${flags.has("-route")} --strict=${flags.has(
"-strict"
)} --skip-install --no-interactive --packageManager=yarn --style=scss`
);
if (flags.has("-subApp")) {
runAndCommit(
`npx ng generate application ${applicationName} --skip-install --no-interactive`,
{ cwd: projectName }
);
}
if (flags.has("-lib")) {
runAndCommit(
`npx ng generate library ${libraryName} --skip-install --no-interactive`,
{ cwd: projectName }
);
}
if (flags.has("-mat")) {
runAndCommit("npx ng add @angular/material --interactive=false --skip-confirmation=true", {
cwd: projectName,
});
}
if (flags.has("-pwa")) {
runAndCommit("npx ng add @angular/pwa --interactive=false --skip-confirmation=true", {
cwd: projectName,
});
}
if (flags.has("-fire")) {
console.error("@angular/fire must be added manually. Run this and commit:");
console.log("cd the-project && npx ng add @angular/fire");
}
rimraf.sync(`${projectName}/node_modules`);
function runAndCommit(command: string, options?: ExecSyncOptions) {
execSync(command, options);
execSync("git add .");
execSync(`git commit -m "${command}"`);
}