flowershow 0.1.7 → 0.1.9

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # flowershow
2
2
 
3
+ ## 0.1.9
4
+
5
+ ### Patch Changes
6
+
7
+ - Kill subprocesses when parent process is terminated.
8
+
9
+ ## 0.1.8
10
+
11
+ ### Patch Changes
12
+
13
+ - Adjust the CLI Installer after migrating Flowershow template to datopian/flowershow-template.
14
+
3
15
  ## 0.1.7
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowershow",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Publish your digital garden",
5
5
  "bin": {
6
6
  "flowershow": "src/bin/cli.js"
@@ -10,15 +10,10 @@ import { exit, error, log, info, success, logWithSpinner, stopSpinner, isSubdir,
10
10
  import { FLOWERSHOW_FOLDER_NAME } from "./const.js";
11
11
  export default class Installer {
12
12
  constructor(context, targetDir) {
13
+ this.templateRepo = "https://github.com/datopian/flowershow-template";
13
14
  this.context = context;
14
15
  this.targetDir = targetDir;
15
16
  }
16
- get templateRepo() {
17
- // simplify importing data from package.json with this line after we no longer want to support node 16
18
- // import packageJson from "#package.json" assert { type: "json" };
19
- const flowershowRepo = require("../../package.json").repository.url.replace("git+", "");
20
- return `${flowershowRepo}/packages/template`;
21
- }
22
17
  async install() {
23
18
  const { context, targetDir, templateRepo } = this;
24
19
  const flowershowDir = path.resolve(targetDir, FLOWERSHOW_FOLDER_NAME);
@@ -131,10 +126,10 @@ export default class Installer {
131
126
  symbol: "🌷",
132
127
  msg: `Creating Flowershow template in ${chalk.magenta(flowershowDir)}`,
133
128
  });
134
- if (existsAction === "overwrite") {
135
- fs.rmSync(flowershowDir, { recursive: true, force: true });
136
- }
137
129
  try {
130
+ if (existsAction === "overwrite") {
131
+ fs.rmSync(flowershowDir, { recursive: true, force: true });
132
+ }
138
133
  const emitter = degit(templateRepo);
139
134
  await emitter.clone(flowershowDir);
140
135
  }
@@ -143,26 +138,40 @@ export default class Installer {
143
138
  log(err);
144
139
  exit(1);
145
140
  }
146
- // remove unneeded dev files
147
- fs.rmSync(`${flowershowDir}/project.json`, { force: true });
148
- fs.rmSync(`${flowershowDir}/.eslintrc.json`, { force: true });
149
- fs.rmSync(`${flowershowDir}/jest.config.js`, { force: true });
150
- // TODO (temporary here) remove Flowershow app home page
151
- fs.rmSync(`${flowershowDir}/pages/index.tsx`, { force: true });
152
- fs.rename(`${flowershowDir}/pages/[...slug].tsx`, `${flowershowDir}/pages/[[...slug]].tsx`, () => { });
153
141
  // update content and assets symlinks
154
- const contentSymlinkPath = path.relative(`${flowershowDir}`, contentDir);
155
- fs.symlinkSync(contentSymlinkPath, `${flowershowDir}/content`, "junction");
156
- if (assetsFolder !== "none") {
157
- const assetsSymlinkPath = path.relative(`${flowershowDir}/public`, `${contentDir}/${assetsFolder}`);
158
- fs.symlinkSync(assetsSymlinkPath, `${flowershowDir}/public/${assetsFolder}`, "junction");
142
+ try {
143
+ // flowershow template includes starter content folder, so we need
144
+ // to remove it before creating symlinks
145
+ if (fs.existsSync(`${flowershowDir}/content`)) {
146
+ fs.rmSync(`${flowershowDir}/content`, { recursive: true, force: true });
147
+ }
148
+ const contentSymlinkPath = path.relative(`${flowershowDir}`, contentDir);
149
+ fs.symlinkSync(contentSymlinkPath, `${flowershowDir}/content`, "junction");
150
+ if (assetsFolder !== "none") {
151
+ const assetsSymlinkPath = path.relative(`${flowershowDir}/public`, `${contentDir}/${assetsFolder}`);
152
+ fs.symlinkSync(assetsSymlinkPath, `${flowershowDir}/public/${assetsFolder}`, "junction");
153
+ }
154
+ stopSpinner();
155
+ log("Created symlinks:");
156
+ log(`${chalk.cyan(`${flowershowDir}/content`)} -> ${chalk.magenta(contentDir)}`);
157
+ if (assetsFolder !== "none") {
158
+ log(`${chalk.cyan(`${flowershowDir}/public/${assetsFolder}`)} -> ${chalk.magenta(`${contentDir}/${assetsFolder}`)}`);
159
+ }
160
+ }
161
+ catch (err) {
162
+ error(`Failed to create symlinks to content and assets folders: ${err.message}`);
163
+ exit(err.exitCode);
159
164
  }
160
165
  // install flowershow dependencies
161
166
  logWithSpinner({ symbol: "🌸", msg: `Installing Flowershow dependencies` });
162
167
  try {
163
- const { stdout, stderr } = await execa("npm", ["install"], {
168
+ const subprocess = execa("npm", ["install"], {
164
169
  cwd: flowershowDir,
165
170
  });
171
+ process.on("SIGINT", () => {
172
+ subprocess.kill("SIGINT");
173
+ });
174
+ const { stdout, stderr } = await subprocess;
166
175
  log(stdout);
167
176
  log(stderr);
168
177
  stopSpinner();
package/src/lib/build.js CHANGED
@@ -12,4 +12,7 @@ export default async function build(dir) {
12
12
  }
13
13
  const subprocess = execa("npm", ["run", "build"], { cwd: flowershowDir });
14
14
  subprocess.stdout.pipe(process.stdout);
15
+ process.on("SIGINT", () => {
16
+ subprocess.kill("SIGINT");
17
+ });
15
18
  }
@@ -5,4 +5,7 @@ export default async function buildExport(dir) {
5
5
  const flowershowDir = path.resolve(dir, FLOWERSHOW_FOLDER_NAME);
6
6
  const subprocess = execa("npm", ["run", "export"], { cwd: flowershowDir });
7
7
  subprocess.stdout.pipe(process.stdout);
8
+ process.on("SIGINT", () => {
9
+ subprocess.kill("SIGINT");
10
+ });
8
11
  }
@@ -12,4 +12,7 @@ export default async function preview(dir) {
12
12
  }
13
13
  const subprocess = execa("npm", ["run", "dev"], { cwd: flowershowDir });
14
14
  subprocess.stdout.pipe(process.stdout);
15
+ process.on("SIGINT", () => {
16
+ subprocess.kill("SIGINT");
17
+ });
15
18
  }