-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify-angular-cli.js
More file actions
executable file
·212 lines (183 loc) · 7.34 KB
/
verify-angular-cli.js
File metadata and controls
executable file
·212 lines (183 loc) · 7.34 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#!/usr/bin/env node
/**
* Verification script for Angular CLI setup
* This script tests that Angular CLI can be used without Nx for the workplace app
*/
const { execSync, spawn } = require('child_process');
const fs = require('fs');
const path = require('path');
console.log('🔍 Verifying Angular CLI Setup for Workplace App\n');
const tests = [
{
name: 'Angular CLI Binary Exists',
test: () => {
const ngPath = path.join(__dirname, 'node_modules', '@angular', 'cli', 'bin', 'ng.js');
if (!fs.existsSync(ngPath)) {
throw new Error(`Angular CLI binary not found at ${ngPath}`);
}
console.log(` ✅ Found Angular CLI at ${ngPath}`);
}
},
{
name: 'angular.json Configuration',
test: () => {
const angularJsonPath = path.join(__dirname, 'angular.json');
if (!fs.existsSync(angularJsonPath)) {
throw new Error('angular.json file not found');
}
const config = JSON.parse(fs.readFileSync(angularJsonPath, 'utf8'));
if (!config.projects.workplace) {
throw new Error('Workplace project not configured in angular.json');
}
const workplaceConfig = config.projects.workplace;
// Check required configurations
const requiredTargets = ['build', 'serve', 'test', 'lint'];
for (const target of requiredTargets) {
if (!workplaceConfig.architect[target]) {
throw new Error(`Missing ${target} configuration for workplace project`);
}
}
console.log(' ✅ angular.json properly configured for workplace project');
console.log(` ✅ Found targets: ${Object.keys(workplaceConfig.architect).join(', ')}`);
}
},
{
name: 'TypeScript Configuration',
test: () => {
const tsconfigPath = path.join(__dirname, 'tsconfig.json');
if (!fs.existsSync(tsconfigPath)) {
throw new Error('Root tsconfig.json not found');
}
const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, 'utf8'));
// Check path mappings for libs
if (!tsconfig.compilerOptions.paths) {
throw new Error('Path mappings not found in tsconfig.json');
}
const expectedPaths = [
'@placeos/common',
'@placeos/components',
'@placeos/bookings'
];
for (const expectedPath of expectedPaths) {
if (!tsconfig.compilerOptions.paths[expectedPath]) {
throw new Error(`Missing path mapping for ${expectedPath}`);
}
}
console.log(' ✅ TypeScript configuration includes library path mappings');
console.log(` ✅ Found ${Object.keys(tsconfig.compilerOptions.paths).length} path mappings`);
}
},
{
name: 'Required Files Exist',
test: () => {
const requiredFiles = [
'apps/workplace/src/main.ts',
'apps/workplace/src/index.html',
'apps/workplace/tsconfig.app.json',
'config/proxy.conf.js',
'apps/workplace/ngsw-config.json'
];
for (const file of requiredFiles) {
const filePath = path.join(__dirname, file);
if (!fs.existsSync(filePath)) {
throw new Error(`Required file not found: ${file}`);
}
}
console.log(' ✅ All required files exist');
}
},
{
name: 'Angular CLI Version Check',
test: () => {
const cmd = 'node node_modules/@angular/cli/bin/ng.js version';
const output = execSync(cmd, { cwd: __dirname, encoding: 'utf8' });
if (!output.includes('Angular CLI:')) {
throw new Error('Angular CLI version command failed');
}
const cliVersionMatch = output.match(/Angular CLI: ([\d.]+)/);
if (cliVersionMatch) {
console.log(` ✅ Angular CLI version: ${cliVersionMatch[1]}`);
}
const angularVersionMatch = output.match(/Angular: ([\d.]+)/);
if (angularVersionMatch) {
console.log(` ✅ Angular framework version: ${angularVersionMatch[1]}`);
}
}
},
{
name: 'Project Recognition',
test: () => {
const cmd = 'node node_modules/@angular/cli/bin/ng.js build workplace --help';
const output = execSync(cmd, { cwd: __dirname, encoding: 'utf8' });
if (!output.includes('workplace')) {
throw new Error('Angular CLI does not recognize workplace project');
}
console.log(' ✅ Angular CLI recognizes workplace project');
}
},
{
name: 'NPM Scripts',
test: () => {
const packageJsonPath = path.join(__dirname, 'package.json');
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
const requiredScripts = [
'ng:start',
'ng:build',
'ng:build:prod',
'ng:test',
'ng:version'
];
for (const script of requiredScripts) {
if (!packageJson.scripts[script]) {
throw new Error(`Missing npm script: ${script}`);
}
}
console.log(' ✅ All Angular CLI npm scripts are configured');
console.log(` ✅ Available scripts: ${requiredScripts.join(', ')}`);
}
},
{
name: 'TypeScript Compilation Check',
test: () => {
try {
const cmd = 'npx tsc --noEmit --project apps/workplace/tsconfig.app.json';
execSync(cmd, { cwd: __dirname, stdio: 'pipe' });
console.log(' ✅ TypeScript compilation successful');
} catch (error) {
throw new Error(`TypeScript compilation failed: ${error.message}`);
}
}
}
];
let passed = 0;
let failed = 0;
console.log('Running verification tests...\n');
for (const test of tests) {
try {
console.log(`🧪 ${test.name}`);
test.test();
passed++;
console.log();
} catch (error) {
console.log(` ❌ ${error.message}\n`);
failed++;
}
}
console.log('📊 Verification Results:');
console.log(` ✅ Passed: ${passed}`);
console.log(` ❌ Failed: ${failed}`);
console.log(` 📈 Success Rate: ${Math.round((passed / tests.length) * 100)}%\n`);
if (failed === 0) {
console.log('🎉 All tests passed! Angular CLI setup is working correctly.');
console.log('\n📝 Quick start commands:');
console.log(' npm run ng:start # Start development server');
console.log(' npm run ng:build # Build for development');
console.log(' npm run ng:build:prod # Build for production');
console.log(' npm run ng:test # Run tests');
console.log('\n📖 For more information, see ANGULAR_CLI_SETUP.md');
process.exit(0);
} else {
console.log('⚠️ Some tests failed. Please check the errors above.');
console.log(' You may need to run the setup steps again or check the configuration.');
process.exit(1);
}