Skip to content

Commit 29c42a1

Browse files
feat(create-analog): simplify prompts add template for upcoming Angular v18 release (#1094)
1 parent aad974d commit 29c42a1

38 files changed

+640
-113
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ Visit the docs at [https://analogjs.org](https://analogjs.org)
1818

1919
## Features
2020

21-
- Supports Vite/Vitest/Playwright
21+
- Powerd by Vite
22+
- Supports Vitest/Storybook
2223
- Server and deployment integrations powered by [Nitro](https://nitro.unjs.io)
2324
- File-based routing
2425
- Server-side data fetching

apps/docs-app/docs/getting-started.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import TabItem from '@theme/TabItem';
1111

1212
Analog requires the following Node and Angular versions:
1313

14-
- Node 16.17.0, or v18.13.0 and higher is recommended
14+
- Node v18.13.0 and higher is recommended
1515
- Angular v15 or higher
1616

1717
## Creating a New Application
@@ -115,3 +115,7 @@ The server for the API/SSR build artifacts is located in the `dist/analog/server
115115

116116
</TabItem>
117117
</Tabs>
118+
119+
## Migrating an Existing Application
120+
121+
You can also migrate an existing Angular application to Analog. See the [migration guide](/docs/guides/migrating) for migration steps.

packages/create-analog/CHANGELOG.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/create-analog/README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ Analog is the fullstack meta-framework for Angular.
44

55
## Features
66

7-
- File-based routing
8-
- SSR/SSG support with prerendering
9-
- Support for API/server routes
7+
- Powerd by Vite
8+
- Supports Vitest/Storybook
9+
- Server and deployment integrations powered by [Nitro](https://nitro.unjs.io)
10+
- Filesystem-based routing
11+
- Server-side data fetching
1012
- Support for using markdown as content routes
11-
- Supports Angular CLI or Nx workspaces
12-
- Powered by Vite
13+
- Integrated API/server routes
14+
- Hybrid SSR/SSG support
15+
- Supports Angular CLI and Nx workspaces
1316

1417
## Creating an Analog Project
1518

@@ -37,9 +40,9 @@ Follow the prompts to install the application dependencies and run the project i
3740

3841
Learn more at [analogjs.org](https://analogjs.org)
3942

40-
## Community
43+
## Supporting Analog
4144

42-
- Visit and Star the [GitHub Repo](https://github.com/analogjs/analog)
45+
- Star the [GitHub Repo](https://github.com/analogjs/analog)
4346
- Join the [Discord](https://chat.analogjs.org)
4447
- Follow us on [Twitter](https://twitter.com/analogjs)
45-
- Become a [Sponsor](https://github.com/sponsors/brandonroberts)
48+
- Become a [Sponsor](https://analogjs.org/docs/sponsoring)

packages/create-analog/__tests__/cli.spec.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const createNonEmptyDir = () => {
2626
writeFileSync(pkgJson, '{ "foo": "bar" }');
2727
};
2828

29-
// Angular v16 starter template
30-
let templateFiles = readdirSync(join(CLI_PATH, 'template-angular-v16'));
29+
// Angular v18 starter template
30+
let templateFiles = readdirSync(join(CLI_PATH, 'template-latest'));
3131
templateFiles.push('.git');
3232
// _gitignore is renamed to .gitignore
3333
templateFiles = templateFiles
@@ -47,23 +47,18 @@ test('prompts for the project name if none supplied', () => {
4747
expect(stdout).toContain('Project name:');
4848
});
4949

50-
test('prompts for the framework if none supplied when target dir is current directory', () => {
50+
test('prompts for the starter if none supplied when target dir is current directory', () => {
5151
mkdirpSync(genPath);
5252
const { stdout } = run(['.'], { cwd: genPath });
53-
expect(stdout).toContain('Select a template:');
53+
expect(stdout).toContain('What would you like to start?:');
5454
});
5555

56-
test('prompts for the framework if none supplied', () => {
56+
test('prompts for the starter if none supplied', () => {
5757
const { stdout } = run([projectName]);
58-
expect(stdout).toContain('Select a template:');
58+
expect(stdout).toContain('What would you like to start?:');
5959
});
6060

61-
test('prompts for the framework on not supplying a value for --template', () => {
62-
const { stdout } = run([projectName, '--template']);
63-
expect(stdout).toContain('Select a template:');
64-
});
65-
66-
test('prompts for the framework on supplying an invalid template', () => {
61+
test.skip('prompts for the framework on supplying an invalid template', () => {
6762
const { stdout } = run([projectName, '--template', 'unknown']);
6863
expect(stdout).toContain(
6964
`"unknown" isn't a valid template. Please choose from below:`
@@ -84,7 +79,7 @@ test('asks to overwrite non-empty current directory', () => {
8479

8580
test('successfully scaffolds a project based on angular starter template', () => {
8681
const { stdout } = run(
87-
[projectName, '--template', 'angular-v16', '--skipTailwind'],
82+
[projectName, '--template', 'latest', '--skipTailwind'],
8883
{
8984
cwd: __dirname,
9085
}
@@ -97,7 +92,7 @@ test('successfully scaffolds a project based on angular starter template', () =>
9792
});
9893

9994
test('works with the -t alias', () => {
100-
const { stdout } = run([projectName, '-t', 'angular-v16', '--skipTailwind'], {
95+
const { stdout } = run([projectName, '-t', 'latest', '--skipTailwind'], {
10196
cwd: __dirname,
10297
});
10398
const generatedFiles = readdirSync(genPath).sort();

packages/create-analog/index.js

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,19 @@ const APPS = [
2020
color: yellow,
2121
variants: [
2222
{
23-
name: 'angular-v17',
24-
display: 'TypeScript',
23+
name: 'Full-stack Application',
24+
template: 'angular-v17',
2525
color: green,
2626
},
2727
{
28-
name: 'blog',
29-
display: 'TypeScript',
30-
color: green,
31-
},
32-
{
33-
name: 'angular-v16',
34-
display: 'TypeScript',
35-
color: green,
28+
name: 'Blog',
29+
template: 'blog',
30+
color: yellow,
3631
},
3732
],
3833
},
3934
];
4035

41-
const TEMPLATES = APPS.map(
42-
(f) => (f.variants && f.variants.map((v) => v.name)) || [f.name]
43-
).reduce((a, b) => a.concat(b), []);
44-
4536
const renameFiles = {
4637
_gitignore: '.gitignore',
4738
};
@@ -97,38 +88,18 @@ async function init() {
9788
isValidPackageName(dir) || 'Invalid package.json name',
9889
},
9990
{
100-
type: template && TEMPLATES.includes(template) ? null : 'select',
101-
name: 'framework',
102-
message:
103-
typeof template === 'string' && !TEMPLATES.includes(template)
104-
? reset(
105-
`"${template}" isn't a valid template. Please choose from below: `
106-
)
107-
: reset('Select a template:'),
108-
initial: 0,
109-
choices: APPS.map((framework) => {
110-
const frameworkColor = framework.color;
91+
type: template ? null : 'select',
92+
name: 'variant',
93+
message: reset('What would you like to start?:'),
94+
// @ts-ignore
95+
choices: APPS[0].variants.map((variant) => {
96+
const variantColor = variant.color;
11197
return {
112-
title: frameworkColor(framework.name),
113-
value: framework,
98+
title: variantColor(variant.name),
99+
value: variant.template,
114100
};
115101
}),
116102
},
117-
{
118-
type: (framework) =>
119-
framework && framework.variants ? 'select' : null,
120-
name: 'variant',
121-
message: reset('Select a variant:'),
122-
// @ts-ignore
123-
choices: (framework) =>
124-
framework.variants.map((variant) => {
125-
const variantColor = variant.color;
126-
return {
127-
title: variantColor(variant.name),
128-
value: variant.name,
129-
};
130-
}),
131-
},
132103
{
133104
type: skipTailwind ? null : 'confirm',
134105
name: 'tailwind',

packages/create-analog/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"template-angular-v16",
1414
"template-angular-v17",
1515
"template-blog",
16+
"template-latest",
1617
"files"
1718
],
1819
"main": "index.js",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
3+
"recommendations": ["angular.ng-template"]
4+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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": "chrome",
8+
"request": "launch",
9+
"preLaunchTask": "npm: start",
10+
"url": "http://localhost:5173/"
11+
},
12+
{
13+
"name": "ng test",
14+
"type": "chrome",
15+
"request": "launch",
16+
"preLaunchTask": "npm: test"
17+
}
18+
]
19+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Analog App
2+
3+
This project was generated with [Analog](https://analogjs.org), the fullstack meta-framework for Angular.
4+
5+
## Setup
6+
7+
Run `npm install` to install the application dependencies.
8+
9+
## Development
10+
11+
Run `npm start` for a dev server. Navigate to `http://localhost:5173/`. The application automatically reloads if you change any of the source files.
12+
13+
## Build
14+
15+
Run `npm run build` to build the client/server project. The client build artifacts are located in the `dist/analog/public` directory. The server for the API build artifacts are located in the `dist/analog/server` directory.
16+
17+
## Test
18+
19+
Run `npm run test` to run unit tests with [Vitest](https://vitest.dev).
20+
21+
## Community
22+
23+
- Visit and Star the [GitHub Repo](https://github.com/analogjs/analog)
24+
- Join the [Discord](https://chat.analogjs.org)
25+
- Follow us on [Twitter](https://twitter.com/analogjs)
26+
- Become a [Sponsor](https://github.com/sponsors/brandonroberts)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
/.nx/cache
34+
.sass-cache/
35+
/connect.lock
36+
/coverage
37+
/libpeerconnection.log
38+
testem.log
39+
/typings
40+
41+
# System files
42+
.DS_Store
43+
Thumbs.db

0 commit comments

Comments
 (0)