flowershow 0.0.7 → 0.0.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 ADDED
@@ -0,0 +1,14 @@
1
+ # flowershow
2
+
3
+ ## 0.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - CLI support for Windows. Symlink files removed from the template.
8
+ - Add information about missing index.md and/or config.js files that the CLI will automatically create for the user.
9
+
10
+ ## 0.0.8
11
+
12
+ ### Patch Changes
13
+
14
+ - Disallow installing the template inside the content folder.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowershow",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Publish your digital garden",
5
5
  "bin": {
6
6
  "flowershow": "src/bin/cli.js"
@@ -35,4 +35,4 @@
35
35
  "engines": {
36
36
  "node": ">=12.2.0 || >=14.13.0"
37
37
  }
38
- }
38
+ }
package/project.json CHANGED
@@ -37,6 +37,5 @@
37
37
  "outputs": ["coverage/packages/cli-e2e"]
38
38
  }
39
39
  },
40
- "tags": [],
41
- "implicitDependencies": ["template"]
40
+ "tags": []
42
41
  }
@@ -12,14 +12,16 @@ import {
12
12
  exit,
13
13
  error,
14
14
  log,
15
+ info,
15
16
  success,
16
17
  logWithSpinner,
17
18
  stopSpinner,
19
+ isSubdir,
18
20
  } from "./utils/index.js";
19
21
 
20
22
  import { FLOWERSHOW_FOLDER_NAME } from "./const.js";
21
23
 
22
- export default class Creator {
24
+ export default class Installer {
23
25
  constructor(context, targetDir) {
24
26
  this.context = context;
25
27
  this.targetDir = targetDir;
@@ -77,12 +79,26 @@ export default class Creator {
77
79
  ]);
78
80
 
79
81
  const contentDir = path.resolve(context, contentPath);
82
+
83
+ // don't allow for installing the template anywhere within the content folder
84
+ // as it will break esbuild
85
+ if (isSubdir(flowershowDir, contentDir)) {
86
+ log(`Provided content directory: ${contentDir}`);
87
+ log(
88
+ `Provided Flowershow template installation directory: ${flowershowDir}`
89
+ );
90
+ error(
91
+ `You can't install the Flowershow template inside your content folder.`
92
+ );
93
+ exit(1);
94
+ }
95
+
80
96
  const assetFolderChoices = fs
81
97
  .readdirSync(contentDir, { withFileTypes: true })
82
98
  .filter((d) => d.isDirectory())
83
99
  .map((d) => ({ name: d.name, value: d.name }));
84
100
 
85
- let assetsFolder = "none";
101
+ let assetsFolder;
86
102
 
87
103
  if (!assetFolderChoices.length) {
88
104
  const { foldersAction } = await inquirer.prompt([
@@ -122,40 +138,13 @@ export default class Creator {
122
138
  }
123
139
 
124
140
  // install flowershow template
125
- logWithSpinner({
126
- symbol: "🌷",
127
- msg: `Installing Flowershow template in ${chalk.magenta(
128
- flowershowDir
129
- )}...`,
130
- });
131
-
132
- if (existsAction === "overwrite") {
133
- fs.rmSync(flowershowDir, { recursive: true, force: true });
134
- }
135
-
136
- try {
137
- const emitter = degit(templateRepo);
138
- await emitter.clone(flowershowDir);
139
- } catch {
140
- error(`Failed to install Flowershow template in ${flowershowDir}.`);
141
- exit(1);
142
- }
143
-
144
- // update content and assets symlinks
145
- fs.unlinkSync(`${flowershowDir}/content`);
146
- fs.symlinkSync(contentDir, `${flowershowDir}/content`);
147
-
148
- fs.unlinkSync(`${flowershowDir}/public/assets`);
149
- if (assetsFolder !== "none") {
150
- fs.symlinkSync(
151
- path.resolve(contentDir, assetsFolder),
152
- `${flowershowDir}/public/${assetsFolder}`
153
- );
154
- }
155
-
156
141
  // // if there is no index.md file, create one
157
142
  if (!fs.existsSync(`${contentPath}/index.md`)) {
143
+ info(
144
+ `No index.md file found in ${contentDir}. Flowershow will create one for you.`
145
+ );
158
146
  const homePageContent = "# Welcome to my Flowershow site!";
147
+ // eslint-disable-next-line no-unused-vars
159
148
  fs.writeFile(
160
149
  `${contentPath}/index.md`,
161
150
  homePageContent,
@@ -166,6 +155,9 @@ export default class Creator {
166
155
 
167
156
  // // if there is no config.js file, create one
168
157
  if (!fs.existsSync(`${contentPath}/config.js`)) {
158
+ info(
159
+ `No config.js file found in ${contentDir}. Flowershow will create one for you.`
160
+ );
169
161
  fs.writeFile(
170
162
  `${contentPath}/config.js`,
171
163
  "{}",
@@ -174,15 +166,42 @@ export default class Creator {
174
166
  );
175
167
  }
176
168
 
177
- // install flowershow dependencies
169
+ // create flowershow template
178
170
  logWithSpinner({
179
- symbol: "🌸",
180
- msg: `Installing Flowershow dependencies...`,
171
+ symbol: "🌷",
172
+ msg: `Creating Flowershow template in ${chalk.magenta(flowershowDir)}`,
181
173
  });
182
174
 
175
+ if (existsAction === "overwrite") {
176
+ fs.rmSync(flowershowDir, { recursive: true, force: true });
177
+ }
178
+
179
+ try {
180
+ const emitter = degit(templateRepo);
181
+ await emitter.clone(flowershowDir);
182
+ } catch {
183
+ error(`Failed to create Flowershow template in ${flowershowDir}.`);
184
+ exit(1);
185
+ }
186
+
187
+ // update content and assets symlinks
188
+ const contentSymlinkPath = path.relative(`${flowershowDir}`, contentDir);
189
+ fs.symlinkSync(contentSymlinkPath, `${flowershowDir}/content`);
190
+
191
+ if (assetsFolder !== "none") {
192
+ const assetsSymlinkPath = path.relative(
193
+ `${flowershowDir}/public`,
194
+ `${contentDir}/${assetsFolder}`
195
+ );
196
+ fs.symlinkSync(
197
+ assetsSymlinkPath,
198
+ `${flowershowDir}/public/${assetsFolder}`
199
+ );
200
+ }
201
+
202
+ // install flowershow dependencies
203
+ logWithSpinner({ symbol: "🌸", msg: `Installing Flowershow dependencies` });
183
204
  try {
184
- // TODO this can be removed after monorepo has been set up correctly
185
- await execa("npm", ["set-script", "prepare", ""], { cwd: flowershowDir });
186
205
  const { stdout, stderr } = await execa("npm", ["install"], {
187
206
  cwd: flowershowDir,
188
207
  });
@@ -191,7 +210,7 @@ export default class Creator {
191
210
  stopSpinner();
192
211
  success("Successfuly installed Flowershow!");
193
212
  } catch (err) {
194
- error(`Installing dependencies failed: ${err.message}`);
213
+ error(`Failed to install Flowershow dependencies: ${err.message}`);
195
214
  exit(err.exitCode);
196
215
  }
197
216
  }
@@ -1,5 +1,6 @@
1
1
  export { error, info, log, success, warn } from "./logger.js";
2
2
  export { exit } from "./exit.js";
3
+ export { isSubdir } from "./isSubdir.js";
3
4
  export {
4
5
  logWithSpinner,
5
6
  stopSpinner,
@@ -0,0 +1,7 @@
1
+ import path from "path";
2
+
3
+ // test if dir is a subdirectory of or same as ofDir
4
+ export function isSubdir(dir, ofDir) {
5
+ const relative = path.relative(ofDir, dir);
6
+ return relative && !relative.startsWith("..") && !path.isAbsolute(relative);
7
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Life Itself
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.