-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimmutable_init.ts
More file actions
83 lines (72 loc) · 2.53 KB
/
immutable_init.ts
File metadata and controls
83 lines (72 loc) · 2.53 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
** Immutable Init **
Initialize a new project with Immutable Stack
- requires a project name as an argument
*/
import { fetch_assets } from "./assets";
import { init_docker } from "./composite/init_docker";
import { init_phoenix_umbrella_app } from "./composite/init_phoenix/init_phoenix_umbrella_app";
import { build_tool_agnostic_init_tasks } from "./composite/init_react/build_tool_agnostic_init_tasks";
import { init_react_app_with_vite } from "./composite/init_react/init_react_app_with_vite";
import { inject_sample_release_mix } from "./injectors/init_docker/inject_sample_release_mix";
import { appDataFromAppnNameSnake, setAppData } from "./readers/get_app_data";
import { execute as exec } from "./runners";
import { setUmbrellaDirCache, writeLog } from "./utils/history_cache";
import { log, setLogLevel } from "./utils/logger";
setLogLevel(5);
const args = process.argv.slice(2);
async function main() {
if (args.length < 1) {
console.error(
"Usage: node init_proj.js <project_name>\n Or: immutable -init <project_name>"
);
process.exit(1);
}
let projectName = args[0]
.toLowerCase()
.replace(/[\s-]/g, "_")
.replace(/[^a-z0-9_]/g, "");
const AppData = appDataFromAppnNameSnake(projectName, false);
setAppData(AppData);
const { AppNameSnake, UmbrellaDir } = AppData;
log(
{ level: 1, color: "GREEN" },
`\n\n Generating ${AppNameSnake} App with Immutable Stack\n\n`
);
setUmbrellaDirCache(UmbrellaDir);
const _dir = await exec(
{ command: `mkdir -p ${AppNameSnake}_umbrella`, dir: UmbrellaDir },
"init_proj"
);
const _docker = await init_docker(AppData);
const _init = await init_phoenix_umbrella_app(AppData);
const _react = await init_react_app_with_vite(AppData);
const _assets = await fetch_assets(AppData);
const _build_tools = await build_tool_agnostic_init_tasks(AppData);
const _release = await inject_sample_release_mix(AppData);
writeLog(UmbrellaDir, `init_project_${projectName}`);
log(
{ level: 1, color: "BLUE" },
`\n\n Retreiving dependencies for React and Phoenix...\n\n`
);
const _deps = await exec(
{
command: `mix deps.get`,
dir: UmbrellaDir,
},
"init_proj"
);
log({ level: 1, color: "BLUE" }, `\n\n Compiling React and Phoenix...\n\n`);
const _compile = await exec(
{
command: `mix compile`,
dir: UmbrellaDir,
},
"init_proj"
);
log(
{ level: 1, color: "GREEN" },
`\n\nInitialization Complete.\n\nGenerated ${projectName}_umbrella`
);
}
main().catch(console.error);