create-analog 0.1.5 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +110 -105
- package/package.json +2 -4
- package/template-angular-v14/README.md +8 -2
- package/template-angular-v14/angular.json +1 -0
- package/template-angular-v14/package.json +12 -7
- package/template-angular-v14/src/app/app.component.spec.ts +5 -5
- package/template-angular-v14/src/test.ts +4 -18
- package/template-angular-v14/tsconfig.app.json +3 -7
- package/template-angular-v14/tsconfig.json +6 -5
- package/template-angular-v14/tsconfig.spec.json +4 -11
- package/template-angular-v14/vite.config.ts +17 -3
- package/CHANGELOG.md +0 -10
- package/template-angular-v14/.gitignore +0 -42
package/index.js
CHANGED
|
@@ -1,27 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// @ts-check
|
|
4
|
-
import fs from 'node:fs'
|
|
5
|
-
import path from 'node:path'
|
|
6
|
-
import { fileURLToPath } from 'node:url'
|
|
7
|
-
import minimist from 'minimist'
|
|
8
|
-
import prompts from 'prompts'
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
cyan,
|
|
12
|
-
green,
|
|
13
|
-
lightRed,
|
|
14
|
-
magenta,
|
|
15
|
-
red,
|
|
16
|
-
reset,
|
|
17
|
-
yellow
|
|
18
|
-
} from 'kolorist'
|
|
19
|
-
import { execSync } from 'node:child_process'
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import minimist from 'minimist';
|
|
8
|
+
import prompts from 'prompts';
|
|
9
|
+
import { red, reset, yellow } from 'kolorist';
|
|
10
|
+
import { execSync } from 'node:child_process';
|
|
20
11
|
|
|
21
12
|
// Avoids autoconversion to number of the project name by defining that the args
|
|
22
13
|
// non associated with an option ( _ ) needs to be parsed as a string. See #4606
|
|
23
|
-
const argv = minimist(process.argv.slice(2), { string: ['_'] })
|
|
24
|
-
const cwd = process.cwd()
|
|
14
|
+
const argv = minimist(process.argv.slice(2), { string: ['_'] });
|
|
15
|
+
const cwd = process.cwd();
|
|
25
16
|
|
|
26
17
|
const APPS = [
|
|
27
18
|
{
|
|
@@ -31,29 +22,29 @@ const APPS = [
|
|
|
31
22
|
{
|
|
32
23
|
name: 'angular-v14',
|
|
33
24
|
display: 'TypeScript',
|
|
34
|
-
color: yellow
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
}
|
|
38
|
-
]
|
|
25
|
+
color: yellow,
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
];
|
|
39
30
|
|
|
40
31
|
const TEMPLATES = APPS.map(
|
|
41
32
|
(f) => (f.variants && f.variants.map((v) => v.name)) || [f.name]
|
|
42
|
-
).reduce((a, b) => a.concat(b), [])
|
|
33
|
+
).reduce((a, b) => a.concat(b), []);
|
|
43
34
|
|
|
44
35
|
const renameFiles = {
|
|
45
|
-
_gitignore: '.gitignore'
|
|
46
|
-
}
|
|
36
|
+
_gitignore: '.gitignore',
|
|
37
|
+
};
|
|
47
38
|
|
|
48
39
|
async function init() {
|
|
49
|
-
let targetDir = formatTargetDir(argv._[0])
|
|
50
|
-
let template = argv.template || argv.t
|
|
40
|
+
let targetDir = formatTargetDir(argv._[0]);
|
|
41
|
+
let template = argv.template || argv.t;
|
|
51
42
|
|
|
52
|
-
const defaultTargetDir = 'analog-project'
|
|
43
|
+
const defaultTargetDir = 'analog-project';
|
|
53
44
|
const getProjectName = () =>
|
|
54
|
-
targetDir === '.' ? path.basename(path.resolve()) : targetDir
|
|
45
|
+
targetDir === '.' ? path.basename(path.resolve()) : targetDir;
|
|
55
46
|
|
|
56
|
-
let result = {}
|
|
47
|
+
let result = {};
|
|
57
48
|
|
|
58
49
|
try {
|
|
59
50
|
result = await prompts(
|
|
@@ -64,8 +55,8 @@ async function init() {
|
|
|
64
55
|
message: reset('Project name:'),
|
|
65
56
|
initial: defaultTargetDir,
|
|
66
57
|
onState: (state) => {
|
|
67
|
-
targetDir = formatTargetDir(state.value) || defaultTargetDir
|
|
68
|
-
}
|
|
58
|
+
targetDir = formatTargetDir(state.value) || defaultTargetDir;
|
|
59
|
+
},
|
|
69
60
|
},
|
|
70
61
|
{
|
|
71
62
|
type: () =>
|
|
@@ -75,16 +66,16 @@ async function init() {
|
|
|
75
66
|
(targetDir === '.'
|
|
76
67
|
? 'Current directory'
|
|
77
68
|
: `Target directory "${targetDir}"`) +
|
|
78
|
-
` is not empty. Remove existing files and continue
|
|
69
|
+
` is not empty. Remove existing files and continue?`,
|
|
79
70
|
},
|
|
80
71
|
{
|
|
81
72
|
type: (_, { overwrite } = {}) => {
|
|
82
73
|
if (overwrite === false) {
|
|
83
|
-
throw new Error(red('✖') + ' Operation cancelled')
|
|
74
|
+
throw new Error(red('✖') + ' Operation cancelled');
|
|
84
75
|
}
|
|
85
|
-
return null
|
|
76
|
+
return null;
|
|
86
77
|
},
|
|
87
|
-
name: 'overwriteChecker'
|
|
78
|
+
name: 'overwriteChecker',
|
|
88
79
|
},
|
|
89
80
|
{
|
|
90
81
|
type: () => (isValidPackageName(getProjectName()) ? null : 'text'),
|
|
@@ -92,7 +83,7 @@ async function init() {
|
|
|
92
83
|
message: reset('Package name:'),
|
|
93
84
|
initial: () => toValidPackageName(getProjectName()),
|
|
94
85
|
validate: (dir) =>
|
|
95
|
-
isValidPackageName(dir) || 'Invalid package.json name'
|
|
86
|
+
isValidPackageName(dir) || 'Invalid package.json name',
|
|
96
87
|
},
|
|
97
88
|
{
|
|
98
89
|
type: template && TEMPLATES.includes(template) ? null : 'select',
|
|
@@ -105,12 +96,12 @@ async function init() {
|
|
|
105
96
|
: reset('Select a template:'),
|
|
106
97
|
initial: 0,
|
|
107
98
|
choices: APPS.map((framework) => {
|
|
108
|
-
const frameworkColor = framework.color
|
|
99
|
+
const frameworkColor = framework.color;
|
|
109
100
|
return {
|
|
110
101
|
title: frameworkColor(framework.name),
|
|
111
|
-
value: framework
|
|
112
|
-
}
|
|
113
|
-
})
|
|
102
|
+
value: framework,
|
|
103
|
+
};
|
|
104
|
+
}),
|
|
114
105
|
},
|
|
115
106
|
{
|
|
116
107
|
type: (framework) =>
|
|
@@ -120,107 +111,105 @@ async function init() {
|
|
|
120
111
|
// @ts-ignore
|
|
121
112
|
choices: (framework) =>
|
|
122
113
|
framework.variants.map((variant) => {
|
|
123
|
-
const variantColor = variant.color
|
|
114
|
+
const variantColor = variant.color;
|
|
124
115
|
return {
|
|
125
116
|
title: variantColor(variant.name),
|
|
126
|
-
value: variant.name
|
|
127
|
-
}
|
|
128
|
-
})
|
|
129
|
-
}
|
|
117
|
+
value: variant.name,
|
|
118
|
+
};
|
|
119
|
+
}),
|
|
120
|
+
},
|
|
130
121
|
],
|
|
131
122
|
{
|
|
132
123
|
onCancel: () => {
|
|
133
|
-
throw new Error(red('✖') + ' Operation cancelled')
|
|
134
|
-
}
|
|
124
|
+
throw new Error(red('✖') + ' Operation cancelled');
|
|
125
|
+
},
|
|
135
126
|
}
|
|
136
|
-
)
|
|
127
|
+
);
|
|
137
128
|
} catch (cancelled) {
|
|
138
|
-
console.log(cancelled.message)
|
|
139
|
-
return
|
|
129
|
+
console.log(cancelled.message);
|
|
130
|
+
return;
|
|
140
131
|
}
|
|
141
132
|
|
|
142
133
|
// user choice associated with prompts
|
|
143
|
-
const { framework, overwrite, packageName, variant } = result
|
|
134
|
+
const { framework, overwrite, packageName, variant } = result;
|
|
144
135
|
|
|
145
|
-
const root = path.join(cwd, targetDir)
|
|
136
|
+
const root = path.join(cwd, targetDir);
|
|
146
137
|
|
|
147
138
|
if (overwrite) {
|
|
148
|
-
emptyDir(root)
|
|
139
|
+
emptyDir(root);
|
|
149
140
|
} else if (!fs.existsSync(root)) {
|
|
150
|
-
fs.mkdirSync(root, { recursive: true })
|
|
141
|
+
fs.mkdirSync(root, { recursive: true });
|
|
151
142
|
}
|
|
152
143
|
|
|
153
144
|
// determine template
|
|
154
|
-
template = variant || framework || template
|
|
145
|
+
template = variant || framework || template;
|
|
155
146
|
|
|
156
|
-
console.log(`\nScaffolding project in ${root}...`)
|
|
147
|
+
console.log(`\nScaffolding project in ${root}...`);
|
|
157
148
|
|
|
158
149
|
const templateDir = path.resolve(
|
|
159
150
|
fileURLToPath(import.meta.url),
|
|
160
151
|
'..',
|
|
161
152
|
`template-${template}`
|
|
162
|
-
)
|
|
153
|
+
);
|
|
163
154
|
|
|
164
155
|
const write = (file, content) => {
|
|
165
156
|
const targetPath = renameFiles[file]
|
|
166
157
|
? path.join(root, renameFiles[file])
|
|
167
|
-
: path.join(root, file)
|
|
158
|
+
: path.join(root, file);
|
|
168
159
|
if (content) {
|
|
169
|
-
fs.writeFileSync(targetPath, content)
|
|
160
|
+
fs.writeFileSync(targetPath, content);
|
|
170
161
|
} else {
|
|
171
|
-
copy(path.join(templateDir, file), targetPath)
|
|
162
|
+
copy(path.join(templateDir, file), targetPath);
|
|
172
163
|
}
|
|
173
|
-
}
|
|
164
|
+
};
|
|
174
165
|
|
|
175
|
-
const files = fs.readdirSync(templateDir)
|
|
166
|
+
const files = fs.readdirSync(templateDir);
|
|
176
167
|
for (const file of files.filter((f) => f !== 'package.json')) {
|
|
177
|
-
write(file)
|
|
168
|
+
write(file);
|
|
178
169
|
}
|
|
179
170
|
|
|
171
|
+
const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent);
|
|
172
|
+
const pkgManager = pkgInfo ? pkgInfo.name : 'npm';
|
|
180
173
|
const pkg = JSON.parse(
|
|
181
174
|
fs.readFileSync(path.join(templateDir, `package.json`), 'utf-8')
|
|
182
|
-
)
|
|
175
|
+
);
|
|
183
176
|
|
|
184
|
-
pkg.name = packageName || getProjectName()
|
|
177
|
+
pkg.name = packageName || getProjectName();
|
|
178
|
+
pkg.scripts.start = getStartCommand(pkgManager);
|
|
185
179
|
|
|
186
|
-
write('package.json', JSON.stringify(pkg, null, 2))
|
|
180
|
+
write('package.json', JSON.stringify(pkg, null, 2));
|
|
187
181
|
|
|
188
182
|
console.log(`\nInitializing git repository:`);
|
|
189
|
-
execSync(`git init ${targetDir} && cd ${targetDir} && git add
|
|
183
|
+
execSync(`git init ${targetDir} && cd ${targetDir} && git add .`);
|
|
190
184
|
|
|
191
|
-
|
|
192
|
-
|
|
185
|
+
// Fail Silent
|
|
186
|
+
// Can fail when user does not have global git credentials
|
|
187
|
+
try {
|
|
188
|
+
execSync(`git commit -m "initial commit"`);
|
|
189
|
+
} catch {}
|
|
193
190
|
|
|
194
|
-
console.log(`\nDone. Now run:\n`)
|
|
191
|
+
console.log(`\nDone. Now run:\n`);
|
|
195
192
|
if (root !== cwd) {
|
|
196
|
-
console.log(` cd ${path.relative(cwd, root)}`)
|
|
197
|
-
}
|
|
198
|
-
switch (pkgManager) {
|
|
199
|
-
case 'yarn':
|
|
200
|
-
console.log(' yarn')
|
|
201
|
-
console.log(' yarn dev')
|
|
202
|
-
break
|
|
203
|
-
default:
|
|
204
|
-
console.log(` ${pkgManager} install`)
|
|
205
|
-
console.log(` ${pkgManager} run dev`)
|
|
206
|
-
break
|
|
193
|
+
console.log(` cd ${path.relative(cwd, root)}`);
|
|
207
194
|
}
|
|
208
|
-
console.log()
|
|
195
|
+
console.log(` ${getInstallCommand(pkgManager)}`);
|
|
196
|
+
console.log(` ${getStartCommand(pkgManager)}`);
|
|
197
|
+
console.log();
|
|
209
198
|
}
|
|
210
199
|
|
|
211
200
|
/**
|
|
212
201
|
* @param {string | undefined} targetDir
|
|
213
202
|
*/
|
|
214
203
|
function formatTargetDir(targetDir) {
|
|
215
|
-
return targetDir?.trim().replace(/\/+$/g, '')
|
|
204
|
+
return targetDir?.trim().replace(/\/+$/g, '');
|
|
216
205
|
}
|
|
217
206
|
|
|
218
207
|
function copy(src, dest) {
|
|
219
|
-
const stat = fs.statSync(src)
|
|
208
|
+
const stat = fs.statSync(src);
|
|
220
209
|
if (stat.isDirectory()) {
|
|
221
|
-
copyDir(src, dest)
|
|
210
|
+
copyDir(src, dest);
|
|
222
211
|
} else {
|
|
223
|
-
fs.copyFileSync(src, dest)
|
|
212
|
+
fs.copyFileSync(src, dest);
|
|
224
213
|
}
|
|
225
214
|
}
|
|
226
215
|
|
|
@@ -230,7 +219,7 @@ function copy(src, dest) {
|
|
|
230
219
|
function isValidPackageName(projectName) {
|
|
231
220
|
return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(
|
|
232
221
|
projectName
|
|
233
|
-
)
|
|
222
|
+
);
|
|
234
223
|
}
|
|
235
224
|
|
|
236
225
|
/**
|
|
@@ -242,7 +231,7 @@ function toValidPackageName(projectName) {
|
|
|
242
231
|
.toLowerCase()
|
|
243
232
|
.replace(/\s+/g, '-')
|
|
244
233
|
.replace(/^[._]/, '')
|
|
245
|
-
.replace(/[^a-z0-9-~]+/g, '-')
|
|
234
|
+
.replace(/[^a-z0-9-~]+/g, '-');
|
|
246
235
|
}
|
|
247
236
|
|
|
248
237
|
/**
|
|
@@ -250,11 +239,11 @@ function toValidPackageName(projectName) {
|
|
|
250
239
|
* @param {string} destDir
|
|
251
240
|
*/
|
|
252
241
|
function copyDir(srcDir, destDir) {
|
|
253
|
-
fs.mkdirSync(destDir, { recursive: true })
|
|
242
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
254
243
|
for (const file of fs.readdirSync(srcDir)) {
|
|
255
|
-
const srcFile = path.resolve(srcDir, file)
|
|
256
|
-
const destFile = path.resolve(destDir, file)
|
|
257
|
-
copy(srcFile, destFile)
|
|
244
|
+
const srcFile = path.resolve(srcDir, file);
|
|
245
|
+
const destFile = path.resolve(destDir, file);
|
|
246
|
+
copy(srcFile, destFile);
|
|
258
247
|
}
|
|
259
248
|
}
|
|
260
249
|
|
|
@@ -262,8 +251,8 @@ function copyDir(srcDir, destDir) {
|
|
|
262
251
|
* @param {string} path
|
|
263
252
|
*/
|
|
264
253
|
function isEmpty(path) {
|
|
265
|
-
const files = fs.readdirSync(path)
|
|
266
|
-
return files.length === 0 || (files.length === 1 && files[0] === '.git')
|
|
254
|
+
const files = fs.readdirSync(path);
|
|
255
|
+
return files.length === 0 || (files.length === 1 && files[0] === '.git');
|
|
267
256
|
}
|
|
268
257
|
|
|
269
258
|
/**
|
|
@@ -271,10 +260,10 @@ function isEmpty(path) {
|
|
|
271
260
|
*/
|
|
272
261
|
function emptyDir(dir) {
|
|
273
262
|
if (!fs.existsSync(dir)) {
|
|
274
|
-
return
|
|
263
|
+
return;
|
|
275
264
|
}
|
|
276
265
|
for (const file of fs.readdirSync(dir)) {
|
|
277
|
-
fs.rmSync(path.resolve(dir, file), { recursive: true, force: true })
|
|
266
|
+
fs.rmSync(path.resolve(dir, file), { recursive: true, force: true });
|
|
278
267
|
}
|
|
279
268
|
}
|
|
280
269
|
|
|
@@ -283,15 +272,31 @@ function emptyDir(dir) {
|
|
|
283
272
|
* @returns object | undefined
|
|
284
273
|
*/
|
|
285
274
|
function pkgFromUserAgent(userAgent) {
|
|
286
|
-
if (!userAgent) return undefined
|
|
287
|
-
const pkgSpec = userAgent.split(' ')[0]
|
|
288
|
-
const pkgSpecArr = pkgSpec.split('/')
|
|
275
|
+
if (!userAgent) return undefined;
|
|
276
|
+
const pkgSpec = userAgent.split(' ')[0];
|
|
277
|
+
const pkgSpecArr = pkgSpec.split('/');
|
|
289
278
|
return {
|
|
290
279
|
name: pkgSpecArr[0],
|
|
291
|
-
version: pkgSpecArr[1]
|
|
292
|
-
}
|
|
280
|
+
version: pkgSpecArr[1],
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* @param {string} pkgManager
|
|
286
|
+
* @returns string
|
|
287
|
+
*/
|
|
288
|
+
function getInstallCommand(pkgManager) {
|
|
289
|
+
return pkgManager === 'yarn' ? 'yarn' : `${pkgManager} install`;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* @param {string} pkgManager
|
|
294
|
+
* @returns string
|
|
295
|
+
*/
|
|
296
|
+
function getStartCommand(pkgManager) {
|
|
297
|
+
return pkgManager === 'yarn' ? 'yarn dev' : `${pkgManager} run dev`;
|
|
293
298
|
}
|
|
294
299
|
|
|
295
300
|
init().catch((e) => {
|
|
296
|
-
console.error(e)
|
|
297
|
-
})
|
|
301
|
+
console.error(e);
|
|
302
|
+
});
|
package/package.json
CHANGED
|
@@ -8,13 +8,19 @@ Run `yarn` to install the application dependencies.
|
|
|
8
8
|
|
|
9
9
|
## Development
|
|
10
10
|
|
|
11
|
-
Run `yarn dev` for a dev server. Navigate to `http://localhost:
|
|
11
|
+
Run `yarn dev` for a dev server. Navigate to `http://localhost:5173/`. The application will automatically reload if you change any of the source files.
|
|
12
12
|
|
|
13
13
|
## Build
|
|
14
14
|
|
|
15
15
|
Run `yarn build` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
16
16
|
|
|
17
|
+
## Test
|
|
18
|
+
|
|
19
|
+
Run `yarn test` to run unit tests with [Vitest](https://vitest.dev).
|
|
20
|
+
|
|
17
21
|
## Community
|
|
18
22
|
|
|
19
23
|
- Join the [Discord](https://discord.gg/mKC2Ec48U5)
|
|
20
|
-
- Visit the [GitHub Repo](https://github.com/analogjs/analog)
|
|
24
|
+
- Visit and Star the [GitHub Repo](https://github.com/analogjs/analog)
|
|
25
|
+
- Visit the [Website](https://analogjs.org/)
|
|
26
|
+
- Follow us on [Twitter](https://twitter.com/analogjs)
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "my-app",
|
|
3
3
|
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=16.0.0"
|
|
7
|
+
},
|
|
4
8
|
"scripts": {
|
|
5
9
|
"dev": "vite",
|
|
6
10
|
"ng": "ng",
|
|
7
11
|
"start": "npm run dev",
|
|
8
12
|
"build": "vite build",
|
|
9
13
|
"watch": "vite build --watch",
|
|
10
|
-
"test": "
|
|
14
|
+
"test": "vitest",
|
|
11
15
|
"postinstall": "vite optimize"
|
|
12
16
|
},
|
|
13
|
-
"private": true,
|
|
14
17
|
"dependencies": {
|
|
15
18
|
"@angular/animations": "^14.0.0",
|
|
16
19
|
"@angular/common": "^14.0.0",
|
|
@@ -20,16 +23,18 @@
|
|
|
20
23
|
"@angular/platform-browser": "^14.0.0",
|
|
21
24
|
"@angular/platform-browser-dynamic": "^14.0.0",
|
|
22
25
|
"@angular/router": "^14.0.0",
|
|
23
|
-
"rxjs": "~7.5.
|
|
24
|
-
"tslib": "^2.
|
|
25
|
-
"zone.js": "~0.11.
|
|
26
|
+
"rxjs": "~7.5.6",
|
|
27
|
+
"tslib": "^2.4.0",
|
|
28
|
+
"zone.js": "~0.11.8"
|
|
26
29
|
},
|
|
27
30
|
"devDependencies": {
|
|
28
31
|
"@analogjs/vite-plugin-angular": "latest",
|
|
29
32
|
"@angular-devkit/build-angular": "^14.0.3",
|
|
30
33
|
"@angular/cli": "~14.0.3",
|
|
31
34
|
"@angular/compiler-cli": "^14.0.0",
|
|
32
|
-
"
|
|
33
|
-
"
|
|
35
|
+
"jsdom": "^20.0.0",
|
|
36
|
+
"typescript": "~4.7.4",
|
|
37
|
+
"vite": "^3.0.9",
|
|
38
|
+
"vitest": "^0.22.1"
|
|
34
39
|
}
|
|
35
40
|
}
|
|
@@ -8,26 +8,26 @@ describe('AppComponent', () => {
|
|
|
8
8
|
imports: [
|
|
9
9
|
RouterTestingModule,
|
|
10
10
|
AppComponent
|
|
11
|
-
]
|
|
11
|
+
]
|
|
12
12
|
}).compileComponents();
|
|
13
13
|
});
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
it('should create the app', () => {
|
|
16
16
|
const fixture = TestBed.createComponent(AppComponent);
|
|
17
17
|
const app = fixture.componentInstance;
|
|
18
18
|
expect(app).toBeTruthy();
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
it(`should have
|
|
21
|
+
it(`should have an initial count of 0`, () => {
|
|
22
22
|
const fixture = TestBed.createComponent(AppComponent);
|
|
23
23
|
const app = fixture.componentInstance;
|
|
24
|
-
expect(app.
|
|
24
|
+
expect(app.count).toEqual(0);
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
it('should render title', () => {
|
|
28
28
|
const fixture = TestBed.createComponent(AppComponent);
|
|
29
29
|
fixture.detectChanges();
|
|
30
30
|
const compiled = fixture.nativeElement as HTMLElement;
|
|
31
|
-
expect(compiled.querySelector('
|
|
31
|
+
expect(compiled.querySelector('h1')?.textContent).toContain('Vite + Angular');
|
|
32
32
|
});
|
|
33
33
|
});
|
|
@@ -1,26 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import '@analogjs/vite-plugin-angular/setup-vitest';
|
|
2
2
|
|
|
3
|
-
import 'zone.js/testing';
|
|
4
|
-
import { getTestBed } from '@angular/core/testing';
|
|
5
3
|
import {
|
|
6
4
|
BrowserDynamicTestingModule,
|
|
7
|
-
platformBrowserDynamicTesting
|
|
5
|
+
platformBrowserDynamicTesting,
|
|
8
6
|
} from '@angular/platform-browser-dynamic/testing';
|
|
7
|
+
import { getTestBed } from '@angular/core/testing';
|
|
9
8
|
|
|
10
|
-
declare const require: {
|
|
11
|
-
context(path: string, deep?: boolean, filter?: RegExp): {
|
|
12
|
-
<T>(id: string): T;
|
|
13
|
-
keys(): string[];
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// First, initialize the Angular testing environment.
|
|
18
9
|
getTestBed().initTestEnvironment(
|
|
19
10
|
BrowserDynamicTestingModule,
|
|
20
|
-
platformBrowserDynamicTesting()
|
|
11
|
+
platformBrowserDynamicTesting()
|
|
21
12
|
);
|
|
22
|
-
|
|
23
|
-
// Then we find all the tests.
|
|
24
|
-
const context = require.context('./', true, /\.spec\.ts$/);
|
|
25
|
-
// And load the modules.
|
|
26
|
-
context.keys().forEach(context);
|
|
@@ -2,14 +2,10 @@
|
|
|
2
2
|
{
|
|
3
3
|
"extends": "./tsconfig.json",
|
|
4
4
|
"compilerOptions": {
|
|
5
|
+
"composite": true,
|
|
5
6
|
"outDir": "./out-tsc/app",
|
|
6
7
|
"types": []
|
|
7
8
|
},
|
|
8
|
-
"files": [
|
|
9
|
-
|
|
10
|
-
"src/polyfills.ts"
|
|
11
|
-
],
|
|
12
|
-
"include": [
|
|
13
|
-
"src/**/*.d.ts"
|
|
14
|
-
]
|
|
9
|
+
"files": ["src/main.ts", "src/polyfills.ts"],
|
|
10
|
+
"include": ["src/**/*.d.ts"]
|
|
15
11
|
}
|
|
@@ -18,15 +18,16 @@
|
|
|
18
18
|
"importHelpers": true,
|
|
19
19
|
"target": "es2020",
|
|
20
20
|
"module": "es2020",
|
|
21
|
-
"lib": [
|
|
22
|
-
"es2020",
|
|
23
|
-
"dom"
|
|
24
|
-
]
|
|
21
|
+
"lib": ["es2020", "dom"]
|
|
25
22
|
},
|
|
26
23
|
"angularCompilerOptions": {
|
|
27
24
|
"enableI18nLegacyMessageIdFormat": false,
|
|
28
25
|
"strictInjectionParameters": true,
|
|
29
26
|
"strictInputAccessModifiers": true,
|
|
30
27
|
"strictTemplates": true
|
|
31
|
-
}
|
|
28
|
+
},
|
|
29
|
+
"references": [
|
|
30
|
+
{ "path": "tsconfig.app.json" },
|
|
31
|
+
{ "path": "tsconfig.spec.json" }
|
|
32
|
+
]
|
|
32
33
|
}
|
|
@@ -2,17 +2,10 @@
|
|
|
2
2
|
{
|
|
3
3
|
"extends": "./tsconfig.json",
|
|
4
4
|
"compilerOptions": {
|
|
5
|
+
"composite": true,
|
|
5
6
|
"outDir": "./out-tsc/spec",
|
|
6
|
-
"types": [
|
|
7
|
-
"jasmine"
|
|
8
|
-
]
|
|
7
|
+
"types": ["node", "vitest/globals"]
|
|
9
8
|
},
|
|
10
|
-
"files": [
|
|
11
|
-
|
|
12
|
-
"src/polyfills.ts"
|
|
13
|
-
],
|
|
14
|
-
"include": [
|
|
15
|
-
"src/**/*.spec.ts",
|
|
16
|
-
"src/**/*.d.ts"
|
|
17
|
-
]
|
|
9
|
+
"files": ["src/test.ts", "src/polyfills.ts"],
|
|
10
|
+
"include": ["src/**/*.spec.ts", "src/**/*.ts"]
|
|
18
11
|
}
|
|
@@ -1,17 +1,31 @@
|
|
|
1
|
+
/// <reference types="vitest" />
|
|
2
|
+
|
|
1
3
|
import { defineConfig } from 'vite';
|
|
2
4
|
import angular from '@analogjs/vite-plugin-angular';
|
|
3
5
|
|
|
4
6
|
// https://vitejs.dev/config/
|
|
5
|
-
export default defineConfig({
|
|
7
|
+
export default defineConfig(({ mode }) => ({
|
|
6
8
|
root: 'src',
|
|
7
9
|
publicDir: 'assets',
|
|
8
10
|
build: {
|
|
9
11
|
outDir: `../dist/my-app`,
|
|
10
12
|
emptyOutDir: true,
|
|
11
|
-
target: 'es2020'
|
|
13
|
+
target: 'es2020',
|
|
12
14
|
},
|
|
13
15
|
resolve: {
|
|
14
16
|
mainFields: ['module'],
|
|
15
17
|
},
|
|
16
18
|
plugins: [angular()],
|
|
17
|
-
|
|
19
|
+
test: {
|
|
20
|
+
globals: true,
|
|
21
|
+
environment: 'jsdom',
|
|
22
|
+
setupFiles: ['test.ts'],
|
|
23
|
+
include: ['**/*.spec.ts'],
|
|
24
|
+
cache: {
|
|
25
|
+
dir: `../node_modules/.vitest`,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
define: {
|
|
29
|
+
'import.meta.vitest': mode !== 'production',
|
|
30
|
+
},
|
|
31
|
+
}));
|
package/CHANGELOG.md
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
|
2
|
-
|
|
3
|
-
# Compiled output
|
|
4
|
-
/dist
|
|
5
|
-
/tmp
|
|
6
|
-
/out-tsc
|
|
7
|
-
/bazel-out
|
|
8
|
-
|
|
9
|
-
# Node
|
|
10
|
-
/node_modules
|
|
11
|
-
npm-debug.log
|
|
12
|
-
yarn-error.log
|
|
13
|
-
|
|
14
|
-
# IDEs and editors
|
|
15
|
-
.idea/
|
|
16
|
-
.project
|
|
17
|
-
.classpath
|
|
18
|
-
.c9/
|
|
19
|
-
*.launch
|
|
20
|
-
.settings/
|
|
21
|
-
*.sublime-workspace
|
|
22
|
-
|
|
23
|
-
# Visual Studio Code
|
|
24
|
-
.vscode/*
|
|
25
|
-
!.vscode/settings.json
|
|
26
|
-
!.vscode/tasks.json
|
|
27
|
-
!.vscode/launch.json
|
|
28
|
-
!.vscode/extensions.json
|
|
29
|
-
.history/*
|
|
30
|
-
|
|
31
|
-
# Miscellaneous
|
|
32
|
-
/.angular/cache
|
|
33
|
-
.sass-cache/
|
|
34
|
-
/connect.lock
|
|
35
|
-
/coverage
|
|
36
|
-
/libpeerconnection.log
|
|
37
|
-
testem.log
|
|
38
|
-
/typings
|
|
39
|
-
|
|
40
|
-
# System files
|
|
41
|
-
.DS_Store
|
|
42
|
-
Thumbs.db
|