From 654487b7f966b24a8bc364106d68bb5d58b37e46 Mon Sep 17 00:00:00 2001 From: Frank Calise Date: Thu, 16 Nov 2023 09:05:57 -0500 Subject: [PATCH 1/3] fix(cli): remove demo markup if keeping demo files --- src/commands/new.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/commands/new.ts b/src/commands/new.ts index 0c89372aa..1a376be83 100644 --- a/src/commands/new.ts +++ b/src/commands/new.ts @@ -682,21 +682,21 @@ module.exports = { // #endregion // #region Remove Demo code - if (removeDemo === true) { - startSpinner(" Removing fancy demo code") - try { - const IGNITE = "node " + filesystem.path(__dirname, "..", "..", "bin", "ignite") + const removeDemoPart = removeDemo === true ? "code" : "markup" + startSpinner(` Removing fancy demo ${removeDemoPart}`) + try { + const IGNITE = "node " + filesystem.path(__dirname, "..", "..", "bin", "ignite") + const CMD = removeDemo === true ? "remove-demo" : "remove-demo-markup" - log(`Ignite bin path: ${IGNITE}`) - await system.run(`${IGNITE} remove-demo ${targetPath}`, { - onProgress: log, - }) - } catch (e) { - log(e) - p(yellow("Unable to remove demo code.")) - } - stopSpinner(" Removing fancy demo code", "🛠️") + log(`Ignite bin path: ${IGNITE}`) + await system.run(`${IGNITE} ${CMD} ${targetPath}`, { + onProgress: log, + }) + } catch (e) { + log(e) + p(yellow(`Unable to remove demo ${removeDemoPart}.`)) } + stopSpinner(` Removing fancy demo ${removeDemoPart}`, "🛠️") // #endregion // #region Format generator templates EOL for Windows From 762fe0ff9fcc1bf4a4364c09582f2add5ea17191 Mon Sep 17 00:00:00 2001 From: Frank Calise Date: Thu, 16 Nov 2023 13:20:12 -0500 Subject: [PATCH 2/3] fix(remove-demo-markup): bump prettier for satisfies TS support --- src/commands/remove-demo-markup.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/remove-demo-markup.ts b/src/commands/remove-demo-markup.ts index 4bb5fb5f6..62cc99b8e 100644 --- a/src/commands/remove-demo-markup.ts +++ b/src/commands/remove-demo-markup.ts @@ -47,7 +47,7 @@ module.exports = { // Run prettier at the end to clean up any spacing issues if (!dryRun) { - await system.run(`npx prettier@2.6.2 --write "./app/**/*.{js,jsx,json,md,ts,tsx}"`, { + await system.run(`npx prettier@2.8.1 --write "./app/**/*.{js,jsx,json,md,ts,tsx}"`, { trim: true, }) } From 0027b2f84db95e064c998c4f9cd46d1bb12090c9 Mon Sep 17 00:00:00 2001 From: Frank Calise Date: Thu, 16 Nov 2023 13:23:08 -0500 Subject: [PATCH 3/3] fix(remove-demo-markup): remove-file deletes --- src/tools/demo.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/tools/demo.ts b/src/tools/demo.ts index 9db53c217..7cf25c1c8 100644 --- a/src/tools/demo.ts +++ b/src/tools/demo.ts @@ -11,10 +11,11 @@ export enum CommentType { /** * Regex pattern to find the various types of // @demo remove-x comments + * Also finds # @demo remove-file for maestro files * * NOTE: This currently will _NOT_ remove a multiline comment */ -export const demoMarkupRegex = /\s*\/\/\s*@demo.*|{?\/.*@demo.*\/}?/gm +export const demoMarkupRegex = /(\/\/|#)\s*@demo.*|{?\/.*@demo.*\/}?/gm /** * Take the file content as a string and remove any @@ -156,7 +157,15 @@ async function update({ const comments: CommentType[] = [] if (await exists(path, REMOVE_FILE)) { - if (!dryRun && !onlyMarkup) filesystem.remove(path) + if (!dryRun) { + if (onlyMarkup) { + const contents = read(path) + const sanitized = demo.sanitize(contents) + filesystem.write(path, sanitized) + } else { + filesystem.remove(path) + } + } comments.push(REMOVE_FILE) return { path, comments } } @@ -167,9 +176,8 @@ async function update({ REMOVE_BLOCK_START, REMOVE_BLOCK_END, ] - const shouldUpdate = onlyMarkup - ? RegExp(demoMarkupRegex, "gm") - : RegExp(operations.join("|"), "g") + + const shouldUpdate = onlyMarkup ? demoMarkupRegex : RegExp(operations.join("|"), "g") if (await exists(path, shouldUpdate)) { const before = read(path)