-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathgenerate-app.js
More file actions
executable file
·130 lines (119 loc) · 5.7 KB
/
generate-app.js
File metadata and controls
executable file
·130 lines (119 loc) · 5.7 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#! /usr/bin/env node
const { execSync } = require('child_process');
const path = require('path');
const fs = require('fs');
if (process.argv.length < 3) {
console.log('You have to provide a name to your new angular app 🤨');
console.log('For example :');
console.log(' npx ng-new-app my-app');
process.exit(1);
}
const projectName = process.argv[2];
const currentPath = process.cwd();
const projectPath = path.join(currentPath, projectName);
const git_repo = 'https://github.com/sardapv/angular-material-starter-template.git';
const features = [
'New Version Updatee: Now Supports, Angular, Tailwind, Jest, Cypress @ Latest',
'-------------------------------------------------------',
'Scalable Project Structure, annotations configured, Global style.scss configured',
'Angular Material Component, Icons, Typography & CDK integrated (just change _variables and colors)',
'Utility first Tailwind CSS, some of the custom configuration added',
'Jest & Cypress (No karma & Protractor)',
'Post build PurgeCSS',
'HTTP Interceptor with Request cloners, baseURL prefixer, session expiry handler, global req-res error handler',
'Boilerplate auth service and auth guard with common methods',
'Global route-loader progressbar',
'Custom broadcaster service utlising RxJs Subject for cross modules, component communication in key:value format',
'ESLint Integrated',
'Prettier Configured (exclusive of ESLint with no conflicts)',
'Husky hooks preventing git commits unless all rules passed',
'source-map-explorer and webpack-bundle-analyzer for prod build inspection of modules, you choose',
'Local prod-build deploy and test on server',
'Github Actions Pipeline configured i.e prettify -> prettify:verify -> lint -> jest & cypress tests -> build -> purgecss -> deploy',
'Prod build console warning, Bunch of custom commands, refer table in readme (https://github.com/sardapv/angular-material-starter-template#readme)',
];
try {
fs.mkdirSync(projectPath);
} catch (err) {
if (err.code === 'EEXIST') {
console.log(`The file ${projectName} already exist in the current directory, please give it another name.`);
} else {
console.log(error);
}
process.exit(1);
}
async function main() {
try {
console.log('\x1b[32m', '--------------------------------------------------------------------', '\x1b[0m');
console.log('\x1b[33m', 'ng-new-app 🚀: Downloading & Setting up the project structure...', '\x1b[0m');
console.log('\x1b[32m', '--------------------------------------------------------------------', '\x1b[0m');
execSync(`git clone --depth 1 ${git_repo} ${projectPath}`, { stdio: 'inherit' });
console.log('step 1/4 ✅');
process.chdir(projectPath);
console.log('\x1b[32m', '------------------------------------------------------', '\x1b[0m');
console.log('\x1b[33m', 'ng-new-app 🚀: Hang on, installing dependencies...', '\x1b[33m');
console.log('\x1b[32m', '------------------------------------------------------', '\x1b[0m');
execSync('npm install', { stdio: 'inherit' });
console.log('step 2/4 ✅');
console.log('\x1b[32m', '--------------------------------------------', '\x1b[0m');
console.log('\x1b[33m', 'ng-new-app 🚀: Cleaning useless stuff...', '\x1b[33m');
console.log('\x1b[32m', '--------------------------------------------', '\x1b[0m');
execSync('npx rimraf ./.git');
execSync('npx rimraf ./bin');
execSync('npx rimraf ./logoForThisRepo.png');
execSync('npx rimraf ./all-contributorsrc');
execSync('npx rimraf ./README.md');
fs.rmdirSync(path.join(projectPath, 'bin'), { recursive: true });
console.log('step 3/4 ✅');
console.log(
'\x1b[32m',
'------------------------------------------------------------------------------------------------- ',
'\x1b[0m'
);
console.log(
'\x1b[33m',
'ng-new-app 🚀: Yay! Boilerplate setup is successful and is ready with all below features! 🎉 ',
'\x1b[33m'
);
console.log(
'\x1b[32m',
'-------------------------------------------------------------------------------------------------',
'\x1b[0m'
);
features.forEach((x, i) => console.log('\x1b[32m', `${i + 1}. ${x}`, '\x1b[33m'));
console.log(
'\x1b[32m',
'-------------------------------------------------------------------------------------------------',
'\x1b[0m'
);
console.log('\x1b[31m', 'Read this before you proceed', '\x1b[0m');
console.log('\x1b[34m', ` 1. cd ${projectName}`);
console.log(` 2. search and replace 'ng-new-app' in all files with your app-name using editor ⚠️`);
console.log(` 3. Edit package.json and change starting details like author, description, git url, etc.`);
console.log(` 4. If API calls supported, configure baseurl in environment*.ts files (don't end with /)`);
console.log(' 5. Run npm start', '\x1b[0m');
console.log();
console.log('step 4/4 ⏳');
console.log();
console.log(
'\x1b[32m',
'Check Readme.md (https://github.com/sardapv/angular-material-starter-template#readme) for more information.',
'\x1b[0m'
);
console.log(
'\x1b[32m',
'-----------------------------------------------------------------------------------------------------------',
'\x1b[0m'
);
console.log();
console.log(
'\x1b[36m',
`If you find any issues, want to suggest enhancements. Welcome to PRs & feedbacks✌🏻!\n Author of this project would love to have your star ⭐️ on repo if you find this helpful 😇.\n Share with your friends! Github Repo: https://github.com/sardapv/angular-material-starter-template`,
'\x1b[0m'
);
console.log();
} catch (error) {
console.log(error);
}
}
main();