Skip to content

Commit 485f870

Browse files
authored
fix: improve Webiny CLI developer-experience (#4455)
1 parent 4ee6137 commit 485f870

File tree

8 files changed

+52
-13
lines changed

8 files changed

+52
-13
lines changed

packages/cli-plugin-deploy-pulumi/commands/newWatch.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ module.exports = async (inputs, context) => {
121121
const learnMoreLink = "https://webiny.link/local-aws-lambda-development";
122122

123123
context.info(`Local AWS Lambda development session started.`);
124-
context.info(
125-
`Note that you should deploy your changes once you're done. To do so, run: %s. Learn more: %s.`,
124+
context.warning(
125+
`Note that once the session is terminated, the %s application will no longer work. To fix this, you %s redeploy it via the %s command. Learn more: %s.`,
126+
projectApplication.name,
127+
"MUST",
126128
deployCommand,
127129
learnMoreLink
128130
);
@@ -141,9 +143,11 @@ module.exports = async (inputs, context) => {
141143
console.log();
142144
console.log();
143145

144-
context.info(`Stopping local AWS Lambda development session.`);
145-
context.info(
146-
`Note that you should deploy your changes. To do so, run: %s. Learn more: %s.`,
146+
context.info(`Terminating local AWS Lambda development session.`);
147+
context.warning(
148+
`Note that once the session is terminated, the %s application will no longer work. To fix this, you %s redeploy it via the %s command. Learn more: %s.`,
149+
projectApplication.name,
150+
"MUST",
147151
deployCommand,
148152
learnMoreLink
149153
);

packages/cli-plugin-deploy-pulumi/commands/newWatch/listPackages.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ const listPackages = async ({ inputs }) => {
5656
? path.join(root, "webiny.config.ts")
5757
: path.join(root, "webiny.config.js");
5858

59+
// We need this because newly introduced extension
60+
// packages do not have a Webiny config file.
61+
if (!fs.existsSync(configPath)) {
62+
continue;
63+
}
64+
5965
packages.push({
6066
name: packageName,
6167
config: require(configPath).default || require(configPath),

packages/cli-plugin-extensions/src/downloadAndLinkExtension.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ export const downloadAndLinkExtension = async ({
159159
console.log(` ‣ ${context.success.hl(p)}`);
160160
});
161161
}
162+
163+
console.log();
164+
console.log(chalk.bold("Additional Notes"));
165+
console.log(
166+
`‣ note that if you already have the ${context.success.hl(
167+
"webiny watch"
168+
)} command running, you'll need to restart it`
169+
);
162170
} catch (e) {
163171
switch (e.code) {
164172
case "NO_OBJECTS_FOUND":

packages/cli-plugin-extensions/src/extensions/AdminExtension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class AdminExtension extends AbstractExtension {
3030
const indexTsxFilePath = `${extensionsFolderPath}/src/index.tsx`;
3131

3232
return [
33-
`run ${chalk.green(watchCommand)} to start a new local development session`,
33+
`run ${chalk.green(watchCommand)} to start local development`,
3434
`open ${chalk.green(indexTsxFilePath)} and start coding`,
3535
`to install additional dependencies, run ${chalk.green(
3636
`yarn workspace ${this.params.packageName} add <package-name>`

packages/cli-plugin-extensions/src/extensions/ApiExtension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class ApiExtension extends AbstractExtension {
3030
const indexTsxFilePath = `${extensionsFolderPath}/src/index.ts`;
3131

3232
return [
33-
`run ${chalk.green(watchCommand)} to start a new local development session`,
33+
`run ${chalk.green(watchCommand)} to start local development`,
3434
`open ${chalk.green(indexTsxFilePath)} and start coding`,
3535
`to install additional dependencies, run ${chalk.green(
3636
`yarn workspace ${this.params.packageName} add <package-name>`

packages/cli-plugin-extensions/src/extensions/PbElementExtension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class PbElementExtension extends AbstractExtension {
3737

3838
return [
3939
[
40-
`run the following commands to start local development sessions:`,
40+
`run the following commands to start local development:`,
4141
` ∙ ${chalk.green(watchCommandAdmin)}`,
4242
` ∙ ${chalk.green(watchCommandWebsite)}`
4343
].join("\n"),

packages/cli-plugin-extensions/src/generateExtension.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ export const generateExtension = async ({ input, ora, context }: GenerateExtensi
158158
console.log(`‣ ${message}`);
159159
});
160160
}
161+
162+
console.log();
163+
console.log(chalk.bold("Additional Notes"));
164+
console.log(
165+
`‣ note that if you already have the ${context.success.hl(
166+
"webiny watch"
167+
)} command running, you'll need to restart it`
168+
);
161169
} catch (err) {
162170
ora.fail("Could not create extension. Please check the logs below.");
163171
console.log();

packages/project-utils/bundling/function/watchFunction.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,29 @@ module.exports = async options => {
3131
}
3232

3333
return new Promise(async (resolve, reject) => {
34-
options.logs && console.log("Compiling...");
34+
let initialCompilation = true;
35+
if (options.logs) {
36+
const message = initialCompilation ? "Initial compilation started..." : "Compiling...";
37+
console.log(message);
38+
}
39+
3540
return webpack(webpackConfig).watch({}, async (err, stats) => {
3641
if (err) {
3742
return reject(err);
3843
}
3944

40-
if (!stats.hasErrors()) {
41-
options.logs && console.log("Compiled successfully.");
42-
} else {
43-
options.logs && console.log(stats.toString("errors-warnings"));
45+
if (!options.logs) {
46+
return;
47+
}
48+
49+
if (stats.hasErrors()) {
50+
console.log(stats.toString("errors-warnings"));
51+
return;
52+
}
53+
54+
if (initialCompilation) {
55+
initialCompilation = false;
56+
console.log("Initial compilation completed. Watching for changes...");
4457
}
4558
});
4659
});

0 commit comments

Comments
 (0)