Skip to content

Commit e87ad06

Browse files
authoredMay 16, 2023
[C3] Design tweaks (#3235)
* Tweaking copy and changing simple worker template option * Updating copy in Angular configuration step

File tree

5 files changed

+31
-28
lines changed

5 files changed

+31
-28
lines changed
 

‎packages/create-cloudflare/src/cli.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const validateType = async (args: PagesGeneratorArgs) => {
8686
question: "What type of application do you want to create?",
8787
options: templateOptions,
8888
renderSubmitted: (option: Option) => {
89-
return `${brandColor("type")} ${dim(option.value)}`;
89+
return `${brandColor("type")} ${dim(option.label)}`;
9090
},
9191
});
9292

@@ -103,11 +103,11 @@ type TemplateConfig = {
103103

104104
const templateMap: Record<string, TemplateConfig> = {
105105
webFramework: {
106-
label: "Web Framework",
106+
label: "Website or web app",
107107
handler: runPagesGenerator,
108108
},
109109
simple: {
110-
label: `Simple Worker`,
110+
label: `"Hello World" script`,
111111
handler: runWorkersGenerator,
112112
},
113113
common: {

‎packages/create-cloudflare/src/common.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export const printSummary = async (ctx: PagesGeneratorContext) => {
167167
const msg = [
168168
`${gray(shapes.leftT)}`,
169169
`${bgGreen(" APPLICATION CREATED ")}`,
170-
`${dim(`Deploy your appliction with`)}`,
170+
`${dim(`Deploy your application with`)}`,
171171
`${blue(
172172
`${npm} run ${ctx.framework?.config.deployCommand ?? "deploy"}`
173173
)}`,

‎packages/create-cloudflare/src/frameworks/angular/index.ts

+23-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { cp, rm } from "node:fs/promises";
22
import { resolve } from "node:path";
3+
import { logRaw } from "helpers/cli";
34
import { brandColor, dim } from "helpers/colors";
45
import {
56
detectPackageManager,
@@ -12,7 +13,7 @@ import { spinner } from "helpers/interactive";
1213
import { getFrameworkVersion } from "../index";
1314
import type { PagesGeneratorContext, FrameworkConfig } from "types";
1415

15-
const { npx } = detectPackageManager();
16+
const { npx, npm } = detectPackageManager();
1617

1718
const generate = async (ctx: PagesGeneratorContext) => {
1819
const version = getFrameworkVersion(ctx);
@@ -21,17 +22,19 @@ const generate = async (ctx: PagesGeneratorContext) => {
2122
ctx,
2223
`${npx} @angular/cli@${version} new ${ctx.project.name} --standalone`
2324
);
25+
26+
logRaw("");
2427
};
2528

2629
const configure = async (ctx: PagesGeneratorContext) => {
2730
process.chdir(ctx.project.path);
2831
await runCommand(`${npx} @angular/cli@next analytics disable`, {
2932
silent: true,
3033
});
31-
await addSSRAdaptor();
34+
await addSSRAdapter();
3235
await installCFWorker(ctx);
3336
await updateAppCode();
34-
await updateAngularJson(ctx);
37+
updateAngularJson(ctx);
3538
};
3639

3740
const config: FrameworkConfig = {
@@ -54,14 +57,14 @@ export default config;
5457

5558
async function installCFWorker(ctx: PagesGeneratorContext) {
5659
const s = spinner();
57-
s.start(`Adding Cloudflare Pages adaptor code`);
60+
s.start(`Adding Cloudflare Pages adapter code`);
5861
await cp(
5962
// eslint-disable-next-line no-restricted-globals
6063
resolve(__dirname, "./angular/templates"),
6164
resolve(ctx.project.path),
6265
{ recursive: true, force: true }
6366
);
64-
s.stop(`${brandColor("added")} ${dim("Cloudflare Pages adaptor code`")}`);
67+
s.stop(`${brandColor("copied")} ${dim("adapter code")}`);
6568

6669
await installPackages(
6770
[
@@ -75,38 +78,38 @@ async function installCFWorker(ctx: PagesGeneratorContext) {
7578
],
7679
{
7780
dev: true,
78-
startText: "Installing adaptor dependencies",
79-
doneText: "Installed",
81+
startText: "Installing adapter dependencies",
82+
doneText: `${brandColor("installed")} ${dim(`via \`${npm} install\``)}`,
8083
}
8184
);
8285
}
8386

84-
async function addSSRAdaptor() {
85-
await runCommand(
86-
`${npx} ng add @nguniversal/express-engine --skip-confirmation`,
87-
{
88-
silent: true,
89-
startText: "Installing Angular SSR",
90-
doneText: `${brandColor("installed")}`,
91-
}
92-
);
87+
async function addSSRAdapter() {
88+
const cmd = `${npx} ng add @nguniversal/express-engine`;
89+
90+
await runCommand(`${cmd} --skip-confirmation`, {
91+
silent: true,
92+
startText: "Installing Angular SSR",
93+
doneText: `${brandColor("installed")} ${dim(`via \`${cmd}\``)}`,
94+
});
9395
}
9496

9597
async function updateAppCode() {
9698
const s = spinner();
9799
s.start(`Updating application code`);
98100

99101
// Add the `provideClientHydration()` provider to the app config.
100-
const appConfig = readFile(resolve("src/app/app.config.ts"));
102+
const appConfigPath = "src/app/app.config.ts";
103+
const appConfig = readFile(resolve(appConfigPath));
101104
const newAppConfig =
102105
"import { provideClientHydration } from '@angular/platform-browser';\n" +
103106
appConfig.replace("providers: [", "providers: [provideClientHydration(), ");
104-
await writeFile(resolve("src/app/app.config.ts"), newAppConfig);
107+
writeFile(resolve(appConfigPath), newAppConfig);
105108

106109
// Remove the unwanted node.js server entry-point
107110
await rm(resolve("server.ts"));
108111

109-
s.stop(`Done updating application code`);
112+
s.stop(`${brandColor(`updated`)} ${dim(appConfigPath)}`);
110113
}
111114

112115
function updateAngularJson(ctx: PagesGeneratorContext) {
@@ -121,5 +124,5 @@ function updateAngularJson(ctx: PagesGeneratorContext) {
121124
delete architectSection["serve-ssr"];
122125

123126
writeFile(resolve("angular.json"), JSON.stringify(angularJson, null, 2));
124-
s.stop(`Updated angular.json config`);
127+
s.stop(`${brandColor(`updated`)} ${dim(`\`angular.json\``)}`);
125128
}

‎packages/create-cloudflare/src/helpers/command.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const runFrameworkGenerator = async (
7474
) => {
7575
endSection(
7676
`Continue with ${ctx.framework?.config.displayName}`,
77-
`Creating your application via \`${cmd.trim()}\``
77+
`via \`${cmd.trim()}\``
7878
);
7979

8080
if (process.env.VITEST) {

‎packages/create-cloudflare/src/workers.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ export const runWorkersGenerator = async (args: Args) => {
2929
await copyFiles(ctx);
3030
await copyExistingWorkerFiles(ctx);
3131
await updateFiles(ctx);
32-
endSection("Project created");
32+
endSection("Application created");
3333

34-
startSection("Installing your dependencies", "Step 2 of 3");
34+
startSection("Installing dependencies", "Step 2 of 3");
3535
chdir(ctx.project.path);
3636
await npmInstall();
3737
endSection("Dependencies Installed");
@@ -47,7 +47,7 @@ async function getTemplate(ctx: Context) {
4747
ctx.args.ts = await confirmInput({
4848
question: "Do you want to use TypeScript?",
4949
renderSubmitted: (value) =>
50-
`${brandColor("typescript")} ${dim(`"${value}"`)}`,
50+
`${brandColor("typescript")} ${dim(`${value ? "yes" : "no"}`)}`,
5151
defaultValue: true,
5252
});
5353
}

0 commit comments

Comments
 (0)
Please sign in to comment.