create-analog 0.1.0

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.
Files changed (30) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/LICENSE +25 -0
  3. package/README.md +50 -0
  4. package/index.js +293 -0
  5. package/package.json +34 -0
  6. package/template-angular-v14/.browserslistrc +16 -0
  7. package/template-angular-v14/.editorconfig +16 -0
  8. package/template-angular-v14/.gitignore +42 -0
  9. package/template-angular-v14/.vscode/extensions.json +4 -0
  10. package/template-angular-v14/.vscode/launch.json +20 -0
  11. package/template-angular-v14/.vscode/tasks.json +42 -0
  12. package/template-angular-v14/README.md +27 -0
  13. package/template-angular-v14/angular.json +19 -0
  14. package/template-angular-v14/package.json +34 -0
  15. package/template-angular-v14/src/app/app.component.spec.ts +33 -0
  16. package/template-angular-v14/src/app/app.component.ts +35 -0
  17. package/template-angular-v14/src/assets/.gitkeep +0 -0
  18. package/template-angular-v14/src/environments/environment.prod.ts +3 -0
  19. package/template-angular-v14/src/environments/environment.ts +16 -0
  20. package/template-angular-v14/src/favicon.ico +0 -0
  21. package/template-angular-v14/src/index.html +14 -0
  22. package/template-angular-v14/src/main.ts +18 -0
  23. package/template-angular-v14/src/polyfills.ts +53 -0
  24. package/template-angular-v14/src/styles.css +1 -0
  25. package/template-angular-v14/src/test.ts +26 -0
  26. package/template-angular-v14/src/vite-env.d.ts +1 -0
  27. package/template-angular-v14/tsconfig.app.json +15 -0
  28. package/template-angular-v14/tsconfig.json +32 -0
  29. package/template-angular-v14/tsconfig.spec.json +18 -0
  30. package/template-angular-v14/vite.config.ts +18 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ <a name="0.0.1"></a>
2
+ ## 0.0.1 (2022-06-25)
3
+
4
+
5
+ ### Features
6
+
7
+ * add v14 templates, README, docs updates ([300de6e](https://github.com/brandonroberts/create-vite/commit/300de6e))
8
+
9
+
10
+
package/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022-present, Brandon Roberts
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ Credit for riginal source code adapted from Vite:
24
+
25
+ https://github.com/brandonroberts/vite/tree/main/packages/create-vite
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # create-analog
2
+
3
+ ## Scaffolding Your First Analog Project
4
+
5
+ With NPM:
6
+
7
+ ```bash
8
+ $ npm create analog@latest
9
+ ```
10
+
11
+ With Yarn:
12
+
13
+ ```bash
14
+ $ yarn create analog
15
+ ```
16
+
17
+ With PNPM:
18
+
19
+ ```bash
20
+ $ pnpm create analog
21
+ ```
22
+
23
+ Then follow the prompts!
24
+
25
+ You can also directly specify the project name and the template you want to use via additional command line options. For example, to scaffold an Angular, run:
26
+
27
+ ```bash
28
+ # npm 6.x
29
+ npm create analog@latest my-angular-app --template angular-v14
30
+
31
+ # npm 7+, extra double-dash is needed:
32
+ npm create analog@latest my-angular-app -- --template angular-v14
33
+
34
+ # yarn
35
+ yarn create analog my-angular-app --template angular-v14
36
+
37
+ # pnpm
38
+ pnpm create analog my-angular-app --template angular-v14
39
+ ```
40
+
41
+ Currently supported template presets include:
42
+
43
+ - `angular-v14`
44
+ - `angular-v14-standalone`
45
+
46
+ You can use `.` for the project name to scaffold in the current directory.
47
+
48
+ ## Credits
49
+
50
+ This project is inspired by `create-vite`.
package/index.js ADDED
@@ -0,0 +1,293 @@
1
+ #!/usr/bin/env node
2
+
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
+ blue,
11
+ cyan,
12
+ green,
13
+ lightRed,
14
+ magenta,
15
+ red,
16
+ reset,
17
+ yellow
18
+ } from 'kolorist'
19
+
20
+ // Avoids autoconversion to number of the project name by defining that the args
21
+ // non associated with an option ( _ ) needs to be parsed as a string. See #4606
22
+ const argv = minimist(process.argv.slice(2), { string: ['_'] })
23
+ const cwd = process.cwd()
24
+
25
+ const APPS = [
26
+ {
27
+ name: 'Analog',
28
+ color: yellow,
29
+ variants: [
30
+ {
31
+ name: 'angular-v14',
32
+ display: 'TypeScript',
33
+ color: yellow
34
+ }
35
+ ]
36
+ }
37
+ ]
38
+
39
+ const TEMPLATES = APPS.map(
40
+ (f) => (f.variants && f.variants.map((v) => v.name)) || [f.name]
41
+ ).reduce((a, b) => a.concat(b), [])
42
+
43
+ const renameFiles = {
44
+ _gitignore: '.gitignore'
45
+ }
46
+
47
+ async function init() {
48
+ let targetDir = formatTargetDir(argv._[0])
49
+ let template = argv.template || argv.t
50
+
51
+ const defaultTargetDir = 'analog-project'
52
+ const getProjectName = () =>
53
+ targetDir === '.' ? path.basename(path.resolve()) : targetDir
54
+
55
+ let result = {}
56
+
57
+ try {
58
+ result = await prompts(
59
+ [
60
+ {
61
+ type: targetDir ? null : 'text',
62
+ name: 'projectName',
63
+ message: reset('Project name:'),
64
+ initial: defaultTargetDir,
65
+ onState: (state) => {
66
+ targetDir = formatTargetDir(state.value) || defaultTargetDir
67
+ }
68
+ },
69
+ {
70
+ type: () =>
71
+ !fs.existsSync(targetDir) || isEmpty(targetDir) ? null : 'confirm',
72
+ name: 'overwrite',
73
+ message: () =>
74
+ (targetDir === '.'
75
+ ? 'Current directory'
76
+ : `Target directory "${targetDir}"`) +
77
+ ` is not empty. Remove existing files and continue?`
78
+ },
79
+ {
80
+ type: (_, { overwrite } = {}) => {
81
+ if (overwrite === false) {
82
+ throw new Error(red('✖') + ' Operation cancelled')
83
+ }
84
+ return null
85
+ },
86
+ name: 'overwriteChecker'
87
+ },
88
+ {
89
+ type: () => (isValidPackageName(getProjectName()) ? null : 'text'),
90
+ name: 'packageName',
91
+ message: reset('Package name:'),
92
+ initial: () => toValidPackageName(getProjectName()),
93
+ validate: (dir) =>
94
+ isValidPackageName(dir) || 'Invalid package.json name'
95
+ },
96
+ {
97
+ type: template && TEMPLATES.includes(template) ? null : 'select',
98
+ name: 'framework',
99
+ message:
100
+ typeof template === 'string' && !TEMPLATES.includes(template)
101
+ ? reset(
102
+ `"${template}" isn't a valid template. Please choose from below: `
103
+ )
104
+ : reset('Select a template:'),
105
+ initial: 0,
106
+ choices: APPS.map((framework) => {
107
+ const frameworkColor = framework.color
108
+ return {
109
+ title: frameworkColor(framework.name),
110
+ value: framework
111
+ }
112
+ })
113
+ },
114
+ {
115
+ type: (framework) =>
116
+ framework && framework.variants ? 'select' : null,
117
+ name: 'variant',
118
+ message: reset('Select a variant:'),
119
+ // @ts-ignore
120
+ choices: (framework) =>
121
+ framework.variants.map((variant) => {
122
+ const variantColor = variant.color
123
+ return {
124
+ title: variantColor(variant.name),
125
+ value: variant.name
126
+ }
127
+ })
128
+ }
129
+ ],
130
+ {
131
+ onCancel: () => {
132
+ throw new Error(red('✖') + ' Operation cancelled')
133
+ }
134
+ }
135
+ )
136
+ } catch (cancelled) {
137
+ console.log(cancelled.message)
138
+ return
139
+ }
140
+
141
+ // user choice associated with prompts
142
+ const { framework, overwrite, packageName, variant } = result
143
+
144
+ const root = path.join(cwd, targetDir)
145
+
146
+ if (overwrite) {
147
+ emptyDir(root)
148
+ } else if (!fs.existsSync(root)) {
149
+ fs.mkdirSync(root, { recursive: true })
150
+ }
151
+
152
+ // determine template
153
+ template = variant || framework || template
154
+
155
+ console.log(`\nScaffolding project in ${root}...`)
156
+
157
+ const templateDir = path.resolve(
158
+ fileURLToPath(import.meta.url),
159
+ '..',
160
+ `template-${template}`
161
+ )
162
+
163
+ const write = (file, content) => {
164
+ const targetPath = renameFiles[file]
165
+ ? path.join(root, renameFiles[file])
166
+ : path.join(root, file)
167
+ if (content) {
168
+ fs.writeFileSync(targetPath, content)
169
+ } else {
170
+ copy(path.join(templateDir, file), targetPath)
171
+ }
172
+ }
173
+
174
+ const files = fs.readdirSync(templateDir)
175
+ for (const file of files.filter((f) => f !== 'package.json')) {
176
+ write(file)
177
+ }
178
+
179
+ const pkg = JSON.parse(
180
+ fs.readFileSync(path.join(templateDir, `package.json`), 'utf-8')
181
+ )
182
+
183
+ pkg.name = packageName || getProjectName()
184
+
185
+ write('package.json', JSON.stringify(pkg, null, 2))
186
+
187
+ const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent)
188
+ const pkgManager = pkgInfo ? pkgInfo.name : 'npm'
189
+
190
+ console.log(`\nDone. Now run:\n`)
191
+ if (root !== cwd) {
192
+ console.log(` cd ${path.relative(cwd, root)}`)
193
+ }
194
+ switch (pkgManager) {
195
+ case 'yarn':
196
+ console.log(' yarn')
197
+ console.log(' yarn start')
198
+ break
199
+ default:
200
+ console.log(` ${pkgManager} install`)
201
+ console.log(` ${pkgManager} start`)
202
+ break
203
+ }
204
+ console.log()
205
+ }
206
+
207
+ /**
208
+ * @param {string | undefined} targetDir
209
+ */
210
+ function formatTargetDir(targetDir) {
211
+ return targetDir?.trim().replace(/\/+$/g, '')
212
+ }
213
+
214
+ function copy(src, dest) {
215
+ const stat = fs.statSync(src)
216
+ if (stat.isDirectory()) {
217
+ copyDir(src, dest)
218
+ } else {
219
+ fs.copyFileSync(src, dest)
220
+ }
221
+ }
222
+
223
+ /**
224
+ * @param {string} projectName
225
+ */
226
+ function isValidPackageName(projectName) {
227
+ return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(
228
+ projectName
229
+ )
230
+ }
231
+
232
+ /**
233
+ * @param {string} projectName
234
+ */
235
+ function toValidPackageName(projectName) {
236
+ return projectName
237
+ .trim()
238
+ .toLowerCase()
239
+ .replace(/\s+/g, '-')
240
+ .replace(/^[._]/, '')
241
+ .replace(/[^a-z0-9-~]+/g, '-')
242
+ }
243
+
244
+ /**
245
+ * @param {string} srcDir
246
+ * @param {string} destDir
247
+ */
248
+ function copyDir(srcDir, destDir) {
249
+ fs.mkdirSync(destDir, { recursive: true })
250
+ for (const file of fs.readdirSync(srcDir)) {
251
+ const srcFile = path.resolve(srcDir, file)
252
+ const destFile = path.resolve(destDir, file)
253
+ copy(srcFile, destFile)
254
+ }
255
+ }
256
+
257
+ /**
258
+ * @param {string} path
259
+ */
260
+ function isEmpty(path) {
261
+ const files = fs.readdirSync(path)
262
+ return files.length === 0 || (files.length === 1 && files[0] === '.git')
263
+ }
264
+
265
+ /**
266
+ * @param {string} dir
267
+ */
268
+ function emptyDir(dir) {
269
+ if (!fs.existsSync(dir)) {
270
+ return
271
+ }
272
+ for (const file of fs.readdirSync(dir)) {
273
+ fs.rmSync(path.resolve(dir, file), { recursive: true, force: true })
274
+ }
275
+ }
276
+
277
+ /**
278
+ * @param {string | undefined} userAgent process.env.npm_config_user_agent
279
+ * @returns object | undefined
280
+ */
281
+ function pkgFromUserAgent(userAgent) {
282
+ if (!userAgent) return undefined
283
+ const pkgSpec = userAgent.split(' ')[0]
284
+ const pkgSpecArr = pkgSpec.split('/')
285
+ return {
286
+ name: pkgSpecArr[0],
287
+ version: pkgSpecArr[1]
288
+ }
289
+ }
290
+
291
+ init().catch((e) => {
292
+ console.error(e)
293
+ })
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "create-analog",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "author": "Brandon Roberts",
7
+ "scripts": {
8
+
9
+ },
10
+ "bin": {
11
+ "create-analog": "index.js"
12
+ },
13
+ "files": [
14
+ "index.js",
15
+ "template-*"
16
+ ],
17
+ "main": "index.js",
18
+ "engines": {
19
+ "node": ">=14.18.0"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/analogjs/analog.git"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/analogjs/analog/issues"
27
+ },
28
+ "homepage": "https://github.com/analogjs/analog/tree/main#readme",
29
+ "dependencies": {
30
+ "kolorist": "^1.5.1",
31
+ "minimist": "^1.2.6",
32
+ "prompts": "^2.4.2"
33
+ }
34
+ }
@@ -0,0 +1,16 @@
1
+ # This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2
+ # For additional information regarding the format and rule options, please see:
3
+ # https://github.com/browserslist/browserslist#queries
4
+
5
+ # For the full list of supported browsers by the Angular framework, please see:
6
+ # https://angular.io/guide/browser-support
7
+
8
+ # You can see what browsers were selected by your queries by running:
9
+ # npx browserslist
10
+
11
+ last 1 Chrome version
12
+ last 1 Firefox version
13
+ last 2 Edge major versions
14
+ last 2 Safari major versions
15
+ last 2 iOS major versions
16
+ Firefox ESR
@@ -0,0 +1,16 @@
1
+ # Editor configuration, see https://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_style = space
7
+ indent_size = 2
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.ts]
12
+ quote_type = single
13
+
14
+ [*.md]
15
+ max_line_length = off
16
+ trim_trailing_whitespace = false
@@ -0,0 +1,42 @@
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
@@ -0,0 +1,4 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
3
+ "recommendations": ["angular.ng-template"]
4
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
3
+ "version": "0.2.0",
4
+ "configurations": [
5
+ {
6
+ "name": "ng serve",
7
+ "type": "pwa-chrome",
8
+ "request": "launch",
9
+ "preLaunchTask": "npm: start",
10
+ "url": "http://localhost:4200/"
11
+ },
12
+ {
13
+ "name": "ng test",
14
+ "type": "chrome",
15
+ "request": "launch",
16
+ "preLaunchTask": "npm: test",
17
+ "url": "http://localhost:9876/debug.html"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
3
+ "version": "2.0.0",
4
+ "tasks": [
5
+ {
6
+ "type": "npm",
7
+ "script": "start",
8
+ "isBackground": true,
9
+ "problemMatcher": {
10
+ "owner": "typescript",
11
+ "pattern": "$tsc",
12
+ "background": {
13
+ "activeOnStart": true,
14
+ "beginsPattern": {
15
+ "regexp": "(.*?)"
16
+ },
17
+ "endsPattern": {
18
+ "regexp": "bundle generation complete"
19
+ }
20
+ }
21
+ }
22
+ },
23
+ {
24
+ "type": "npm",
25
+ "script": "test",
26
+ "isBackground": true,
27
+ "problemMatcher": {
28
+ "owner": "typescript",
29
+ "pattern": "$tsc",
30
+ "background": {
31
+ "activeOnStart": true,
32
+ "beginsPattern": {
33
+ "regexp": "(.*?)"
34
+ },
35
+ "endsPattern": {
36
+ "regexp": "bundle generation complete"
37
+ }
38
+ }
39
+ }
40
+ }
41
+ ]
42
+ }
@@ -0,0 +1,27 @@
1
+ # MyApp
2
+
3
+ This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 14.0.3.
4
+
5
+ ## Development server
6
+
7
+ Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
8
+
9
+ ## Code scaffolding
10
+
11
+ Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
12
+
13
+ ## Build
14
+
15
+ Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
16
+
17
+ ## Running unit tests
18
+
19
+ Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20
+
21
+ ## Running end-to-end tests
22
+
23
+ Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
24
+
25
+ ## Further help
26
+
27
+ To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3
+ "version": 1,
4
+ "cli": {
5
+ "packageManager": "yarn"
6
+ },
7
+ "newProjectRoot": "projects",
8
+ "projects": {
9
+ "my-app": {
10
+ "projectType": "application",
11
+ "schematics": {},
12
+ "root": "",
13
+ "sourceRoot": "src",
14
+ "prefix": "app",
15
+ "architect": {
16
+ }
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "my-app",
3
+ "version": "0.0.0",
4
+ "scripts": {
5
+ "dev": "vite",
6
+ "ng": "ng",
7
+ "start": "npm run dev",
8
+ "build": "vite build",
9
+ "watch": "vite build --watch",
10
+ "test": "ng test"
11
+ },
12
+ "private": true,
13
+ "dependencies": {
14
+ "@angular/animations": "^14.0.0",
15
+ "@angular/common": "^14.0.0",
16
+ "@angular/compiler": "^14.0.0",
17
+ "@angular/core": "^14.0.0",
18
+ "@angular/forms": "^14.0.0",
19
+ "@angular/platform-browser": "^14.0.0",
20
+ "@angular/platform-browser-dynamic": "^14.0.0",
21
+ "@angular/router": "^14.0.0",
22
+ "rxjs": "~7.5.0",
23
+ "tslib": "^2.3.0",
24
+ "zone.js": "~0.11.4"
25
+ },
26
+ "devDependencies": {
27
+ "@analogjs/vite-plugin-angular": "^0.1.0",
28
+ "@angular-devkit/build-angular": "^14.0.3",
29
+ "@angular/cli": "~14.0.3",
30
+ "@angular/compiler-cli": "^14.0.0",
31
+ "typescript": "~4.7.2",
32
+ "vite": "^2.9.13"
33
+ }
34
+ }
@@ -0,0 +1,33 @@
1
+ import { TestBed } from '@angular/core/testing';
2
+ import { RouterTestingModule } from '@angular/router/testing';
3
+ import { AppComponent } from './app.component';
4
+
5
+ describe('AppComponent', () => {
6
+ beforeEach(async () => {
7
+ await TestBed.configureTestingModule({
8
+ imports: [
9
+ RouterTestingModule,
10
+ AppComponent
11
+ ],
12
+ }).compileComponents();
13
+ });
14
+
15
+ it('should create the app', () => {
16
+ const fixture = TestBed.createComponent(AppComponent);
17
+ const app = fixture.componentInstance;
18
+ expect(app).toBeTruthy();
19
+ });
20
+
21
+ it(`should have as title 'my-app'`, () => {
22
+ const fixture = TestBed.createComponent(AppComponent);
23
+ const app = fixture.componentInstance;
24
+ expect(app.title).toEqual('my-app');
25
+ });
26
+
27
+ it('should render title', () => {
28
+ const fixture = TestBed.createComponent(AppComponent);
29
+ fixture.detectChanges();
30
+ const compiled = fixture.nativeElement as HTMLElement;
31
+ expect(compiled.querySelector('.content span')?.textContent).toContain('my-app app is running!');
32
+ });
33
+ });
@@ -0,0 +1,35 @@
1
+ import { Component } from '@angular/core';
2
+ import { RouterModule } from '@angular/router';
3
+
4
+ @Component({
5
+ selector: 'app-root',
6
+ standalone: true,
7
+ imports: [RouterModule],
8
+ template: `
9
+ <!--The content below is only a placeholder and can be replaced.-->
10
+ <div style="text-align:center" class="content">
11
+ <h1>
12
+ Welcome to {{title}}!
13
+ </h1>
14
+ <span style="display: block">{{ title }} app is running!</span>
15
+ <img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
16
+ </div>
17
+ <h2>Here are some links to help you start: </h2>
18
+ <ul>
19
+ <li>
20
+ <h2><a target="_blank" rel="noopener" href="https://angular.io/tutorial">Tour of Heroes</a></h2>
21
+ </li>
22
+ <li>
23
+ <h2><a target="_blank" rel="noopener" href="https://angular.io/cli">CLI Documentation</a></h2>
24
+ </li>
25
+ <li>
26
+ <h2><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></h2>
27
+ </li>
28
+ </ul>
29
+ <router-outlet></router-outlet>
30
+ `,
31
+ styles: []
32
+ })
33
+ export class AppComponent {
34
+ title = 'my-app';
35
+ }
File without changes
@@ -0,0 +1,3 @@
1
+ export const environment = {
2
+ production: true
3
+ };
@@ -0,0 +1,16 @@
1
+ // This file can be replaced during build by using the `fileReplacements` array.
2
+ // `ng build` replaces `environment.ts` with `environment.prod.ts`.
3
+ // The list of file replacements can be found in `angular.json`.
4
+
5
+ export const environment = {
6
+ production: false
7
+ };
8
+
9
+ /*
10
+ * For easier debugging in development mode, you can import the following file
11
+ * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
12
+ *
13
+ * This import should be commented out in production mode because it will have a negative impact
14
+ * on performance if an error is thrown.
15
+ */
16
+ // import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
@@ -0,0 +1,14 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>MyApp</title>
6
+ <base href="/">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1">
8
+ <link rel="icon" type="image/x-icon" href="favicon.ico">
9
+ </head>
10
+ <body>
11
+ <app-root></app-root>
12
+ <script type="module" src="/main.ts"></script>
13
+ </body>
14
+ </html>
@@ -0,0 +1,18 @@
1
+ import './polyfills';
2
+ import { enableProdMode, importProvidersFrom } from '@angular/core';
3
+ import { bootstrapApplication } from '@angular/platform-browser';
4
+ import { RouterModule, Routes } from '@angular/router';
5
+
6
+ import { AppComponent } from './app/app.component';
7
+
8
+ if (import.meta.env.PROD) {
9
+ enableProdMode();
10
+ }
11
+
12
+ const routes: Routes = [];
13
+
14
+ bootstrapApplication(AppComponent, {
15
+ providers: [
16
+ importProvidersFrom(RouterModule.forRoot(routes))
17
+ ]
18
+ });
@@ -0,0 +1,53 @@
1
+ /**
2
+ * This file includes polyfills needed by Angular and is loaded before the app.
3
+ * You can add your own extra polyfills to this file.
4
+ *
5
+ * This file is divided into 2 sections:
6
+ * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7
+ * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8
+ * file.
9
+ *
10
+ * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11
+ * automatically update themselves. This includes recent versions of Safari, Chrome (including
12
+ * Opera), Edge on the desktop, and iOS and Chrome on mobile.
13
+ *
14
+ * Learn more in https://angular.io/guide/browser-support
15
+ */
16
+
17
+ /***************************************************************************************************
18
+ * BROWSER POLYFILLS
19
+ */
20
+
21
+ /**
22
+ * By default, zone.js will patch all possible macroTask and DomEvents
23
+ * user can disable parts of macroTask/DomEvents patch by setting following flags
24
+ * because those flags need to be set before `zone.js` being loaded, and webpack
25
+ * will put import in the top of bundle, so user need to create a separate file
26
+ * in this directory (for example: zone-flags.ts), and put the following flags
27
+ * into that file, and then add the following code before importing zone.js.
28
+ * import './zone-flags';
29
+ *
30
+ * The flags allowed in zone-flags.ts are listed here.
31
+ *
32
+ * The following flags will work for all browsers.
33
+ *
34
+ * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
35
+ * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
36
+ * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
37
+ *
38
+ * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
39
+ * with the following flag, it will bypass `zone.js` patch for IE/Edge
40
+ *
41
+ * (window as any).__Zone_enable_cross_context_check = true;
42
+ *
43
+ */
44
+
45
+ /***************************************************************************************************
46
+ * Zone JS is required by default for Angular itself.
47
+ */
48
+ import 'zone.js'; // Included with Angular CLI.
49
+
50
+
51
+ /***************************************************************************************************
52
+ * APPLICATION IMPORTS
53
+ */
@@ -0,0 +1 @@
1
+ /* You can add global styles to this file, and also import other style files */
@@ -0,0 +1,26 @@
1
+ // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2
+
3
+ import 'zone.js/testing';
4
+ import { getTestBed } from '@angular/core/testing';
5
+ import {
6
+ BrowserDynamicTestingModule,
7
+ platformBrowserDynamicTesting
8
+ } from '@angular/platform-browser-dynamic/testing';
9
+
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
+ getTestBed().initTestEnvironment(
19
+ BrowserDynamicTestingModule,
20
+ platformBrowserDynamicTesting(),
21
+ );
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);
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -0,0 +1,15 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "extends": "./tsconfig.json",
4
+ "compilerOptions": {
5
+ "outDir": "./out-tsc/app",
6
+ "types": []
7
+ },
8
+ "files": [
9
+ "src/main.ts",
10
+ "src/polyfills.ts"
11
+ ],
12
+ "include": [
13
+ "src/**/*.d.ts"
14
+ ]
15
+ }
@@ -0,0 +1,32 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "compileOnSave": false,
4
+ "compilerOptions": {
5
+ "baseUrl": "./",
6
+ "outDir": "./dist/out-tsc",
7
+ "forceConsistentCasingInFileNames": true,
8
+ "strict": true,
9
+ "noImplicitOverride": true,
10
+ "noPropertyAccessFromIndexSignature": true,
11
+ "noImplicitReturns": true,
12
+ "noFallthroughCasesInSwitch": true,
13
+ "sourceMap": true,
14
+ "declaration": false,
15
+ "downlevelIteration": true,
16
+ "experimentalDecorators": true,
17
+ "moduleResolution": "node",
18
+ "importHelpers": true,
19
+ "target": "es2020",
20
+ "module": "es2020",
21
+ "lib": [
22
+ "es2020",
23
+ "dom"
24
+ ]
25
+ },
26
+ "angularCompilerOptions": {
27
+ "enableI18nLegacyMessageIdFormat": false,
28
+ "strictInjectionParameters": true,
29
+ "strictInputAccessModifiers": true,
30
+ "strictTemplates": true
31
+ }
32
+ }
@@ -0,0 +1,18 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "extends": "./tsconfig.json",
4
+ "compilerOptions": {
5
+ "outDir": "./out-tsc/spec",
6
+ "types": [
7
+ "jasmine"
8
+ ]
9
+ },
10
+ "files": [
11
+ "src/test.ts",
12
+ "src/polyfills.ts"
13
+ ],
14
+ "include": [
15
+ "src/**/*.spec.ts",
16
+ "src/**/*.d.ts"
17
+ ]
18
+ }
@@ -0,0 +1,18 @@
1
+ import { defineConfig } from 'vite';
2
+ import angular from '@analogjs/vite-plugin-angular';
3
+
4
+ // https://vitejs.dev/config/
5
+ export default defineConfig({
6
+ root: 'src',
7
+ optimizeDeps: {
8
+ exclude: ['rxjs']
9
+ },
10
+ build: {
11
+ outDir: `dist/my-app`,
12
+ emptyOutDir: true
13
+ },
14
+ resolve: {
15
+ mainFields: ['module'],
16
+ },
17
+ plugins: [angular()],
18
+ });