flowershow 0.1.8 → 0.1.10
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/{src → dist}/lib/Installer.js +6 -2
- package/{src → dist}/lib/build.js +3 -0
- package/{src → dist}/lib/buildExport.js +3 -0
- package/{src → dist}/lib/preview.js +3 -0
- package/dist/src/bin/cli.js +97 -0
- package/dist/src/index.js +1 -0
- package/dist/src/lib/Installer.js +185 -0
- package/dist/src/lib/build.js +18 -0
- package/dist/src/lib/buildExport.js +11 -0
- package/dist/src/lib/const.js +1 -0
- package/dist/src/lib/install.js +28 -0
- package/dist/src/lib/preview.js +18 -0
- package/dist/src/lib/publish.js +8 -0
- package/dist/src/lib/upgrade.js +8 -0
- package/dist/src/lib/utils/exit.js +3 -0
- package/dist/src/lib/utils/index.js +5 -0
- package/dist/src/lib/utils/isSubdir.js +6 -0
- package/dist/src/lib/utils/logger.js +19 -0
- package/dist/src/lib/utils/sendEvent.js +5 -0
- package/dist/src/lib/utils/spinner.js +49 -0
- package/package.json +16 -5
- package/CHANGELOG.md +0 -68
- /package/{src → dist}/bin/cli.js +0 -0
- /package/{src → dist}/index.js +0 -0
- /package/{src → dist}/lib/const.js +0 -0
- /package/{src → dist}/lib/install.js +0 -0
- /package/{src → dist}/lib/publish.js +0 -0
- /package/{src → dist}/lib/upgrade.js +0 -0
- /package/{src → dist}/lib/utils/exit.js +0 -0
- /package/{src → dist}/lib/utils/index.js +0 -0
- /package/{src → dist}/lib/utils/isSubdir.js +0 -0
- /package/{src → dist}/lib/utils/logger.js +0 -0
- /package/{src → dist}/lib/utils/sendEvent.js +0 -0
- /package/{src → dist}/lib/utils/spinner.js +0 -0
|
@@ -10,7 +10,7 @@ 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
|
|
13
|
+
this.templateRepo = "https://github.com/datopian/flowershow";
|
|
14
14
|
this.context = context;
|
|
15
15
|
this.targetDir = targetDir;
|
|
16
16
|
}
|
|
@@ -165,9 +165,13 @@ export default class Installer {
|
|
|
165
165
|
// install flowershow dependencies
|
|
166
166
|
logWithSpinner({ symbol: "🌸", msg: `Installing Flowershow dependencies` });
|
|
167
167
|
try {
|
|
168
|
-
const
|
|
168
|
+
const subprocess = execa("npm", ["install"], {
|
|
169
169
|
cwd: flowershowDir,
|
|
170
170
|
});
|
|
171
|
+
process.on("SIGINT", () => {
|
|
172
|
+
subprocess.kill("SIGINT");
|
|
173
|
+
});
|
|
174
|
+
const { stdout, stderr } = await subprocess;
|
|
171
175
|
log(stdout);
|
|
172
176
|
log(stderr);
|
|
173
177
|
stopSpinner();
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
const require = createRequire(import.meta.url);
|
|
4
|
+
import { warn, exit, sendEvent } from "../lib/utils/index.js";
|
|
5
|
+
import { Command } from "commander";
|
|
6
|
+
// TODO check current vs required node version (package.json engines)
|
|
7
|
+
// const requiredNodeVersion = require("../package.json").engines.node;
|
|
8
|
+
const { version: cli } = require("../../package.json");
|
|
9
|
+
// simplify importing data from package.json with this line after we no longer want to support node 16
|
|
10
|
+
// import packageJson from "#package.json" assert { type: "json" };
|
|
11
|
+
const { version: node, platform, argv } = process;
|
|
12
|
+
if (platform === "win32") {
|
|
13
|
+
warn("This may not work as expected. You're trying to run Flowershow CLI on Windows, which is not thoroughly tested. Please submit an issue if you encounter any problems: https://github.com/flowershow/flowershow/issues");
|
|
14
|
+
}
|
|
15
|
+
const [, , cmd, ...args] = argv;
|
|
16
|
+
sendEvent({
|
|
17
|
+
event: "cli-usage",
|
|
18
|
+
action: cmd,
|
|
19
|
+
meta: {
|
|
20
|
+
args,
|
|
21
|
+
cli,
|
|
22
|
+
node,
|
|
23
|
+
platform,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
process.on("uncaughtException", () => {
|
|
27
|
+
sendEvent({
|
|
28
|
+
event: "cli-error",
|
|
29
|
+
action: cmd,
|
|
30
|
+
meta: {
|
|
31
|
+
args,
|
|
32
|
+
cli,
|
|
33
|
+
node,
|
|
34
|
+
platform,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
exit(1);
|
|
38
|
+
});
|
|
39
|
+
// CLI commands
|
|
40
|
+
const program = new Command();
|
|
41
|
+
program
|
|
42
|
+
.description("CLI tool for creating, publishing and upgrading Flowershow apps")
|
|
43
|
+
.version(require("../../package.json").version)
|
|
44
|
+
.usage("<command> [options]");
|
|
45
|
+
// choose template
|
|
46
|
+
program
|
|
47
|
+
.command("install")
|
|
48
|
+
.description("install Flowershow template in target directory")
|
|
49
|
+
.argument("[target-dir]", "Path to the folder where you want Flowershow template to be installed", ".")
|
|
50
|
+
// .option('-t, --template [template-name]', 'Flowershow template name to use', 'default')
|
|
51
|
+
.action(async (targetDir) => {
|
|
52
|
+
const { default: install } = await import("../lib/install.js");
|
|
53
|
+
install(targetDir);
|
|
54
|
+
});
|
|
55
|
+
program
|
|
56
|
+
.command("build")
|
|
57
|
+
.description("build Flowershow website")
|
|
58
|
+
.argument("[project-dir]", "Path to the folder where Flowershow template is installed (root folder of .flowershow)", ".")
|
|
59
|
+
.action(async (projectPath) => {
|
|
60
|
+
const { default: build } = await import("../lib/build.js");
|
|
61
|
+
build(projectPath);
|
|
62
|
+
});
|
|
63
|
+
program
|
|
64
|
+
.command("export")
|
|
65
|
+
.description("build a static Flowershow website")
|
|
66
|
+
.argument("[project-dir]", "Path to the folder where Flowershow template is installed (root folder of .flowershow)", ".")
|
|
67
|
+
.action(async (projectPath) => {
|
|
68
|
+
const { default: buildExport } = await import("../lib/buildExport.js");
|
|
69
|
+
buildExport(projectPath);
|
|
70
|
+
});
|
|
71
|
+
program
|
|
72
|
+
.command("preview")
|
|
73
|
+
.description("preview your Flowershow site")
|
|
74
|
+
.argument("[project-dir]", "Path to the folder where Flowershow template is installed (root folder of .flowershow)", ".")
|
|
75
|
+
.action(async (projectPath) => {
|
|
76
|
+
const { default: preview } = await import("../lib/preview.js");
|
|
77
|
+
preview(projectPath);
|
|
78
|
+
});
|
|
79
|
+
// TBD
|
|
80
|
+
program
|
|
81
|
+
.command("publish")
|
|
82
|
+
.description("publish files or directories")
|
|
83
|
+
.argument("[path]", "path to a file or a directory", ".")
|
|
84
|
+
.option("-g, --glob <pattern>", "glob pattern")
|
|
85
|
+
.action(async () => {
|
|
86
|
+
const { default: publish } = await import("../lib/publish.js");
|
|
87
|
+
publish();
|
|
88
|
+
});
|
|
89
|
+
// TBD
|
|
90
|
+
program
|
|
91
|
+
.command("upgrade")
|
|
92
|
+
.description("upgrade your Flowershow template to the latest version")
|
|
93
|
+
.action(async () => {
|
|
94
|
+
const { default: upgrade } = await import("../lib/upgrade.js");
|
|
95
|
+
upgrade();
|
|
96
|
+
});
|
|
97
|
+
program.parse();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// export * from './lib/cli';
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
3
|
+
import * as fs from "fs";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import degit from "degit";
|
|
7
|
+
import { execa } from "execa";
|
|
8
|
+
import inquirer from "inquirer";
|
|
9
|
+
import { exit, error, log, info, success, logWithSpinner, stopSpinner, isSubdir, } from "./utils/index.js";
|
|
10
|
+
import { FLOWERSHOW_FOLDER_NAME } from "./const.js";
|
|
11
|
+
export default class Installer {
|
|
12
|
+
constructor(context, targetDir) {
|
|
13
|
+
this.templateRepo = "https://github.com/datopian/flowershow";
|
|
14
|
+
this.context = context;
|
|
15
|
+
this.targetDir = targetDir;
|
|
16
|
+
}
|
|
17
|
+
async install() {
|
|
18
|
+
const { context, targetDir, templateRepo } = this;
|
|
19
|
+
const flowershowDir = path.resolve(targetDir, FLOWERSHOW_FOLDER_NAME);
|
|
20
|
+
let existsAction;
|
|
21
|
+
if (fs.existsSync(flowershowDir)) {
|
|
22
|
+
const { action } = await inquirer.prompt([
|
|
23
|
+
{
|
|
24
|
+
name: "action",
|
|
25
|
+
type: "list",
|
|
26
|
+
message: `Flowershow template is already installed in directory ${chalk.magenta(targetDir)}. What do you want to do?:`,
|
|
27
|
+
choices: [
|
|
28
|
+
{ name: "Overwrite", value: "overwrite" },
|
|
29
|
+
// { name: 'Merge', value: 'merge' },
|
|
30
|
+
{ name: "Cancel", value: null },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
]);
|
|
34
|
+
if (!action) {
|
|
35
|
+
exit(0);
|
|
36
|
+
}
|
|
37
|
+
existsAction = action;
|
|
38
|
+
}
|
|
39
|
+
const { contentPath } = await inquirer.prompt([
|
|
40
|
+
{
|
|
41
|
+
name: "contentPath",
|
|
42
|
+
type: "input",
|
|
43
|
+
message: "Path to the folder with your markdown files",
|
|
44
|
+
validate(input) {
|
|
45
|
+
const contentDir = path.resolve(context, input);
|
|
46
|
+
if (!fs.existsSync(contentDir)) {
|
|
47
|
+
error(`Directory ${contentDir} does not exist.`);
|
|
48
|
+
exit(1);
|
|
49
|
+
}
|
|
50
|
+
return true;
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
]);
|
|
54
|
+
const contentDir = path.resolve(context, contentPath);
|
|
55
|
+
// don't allow for installing the template anywhere within the content folder
|
|
56
|
+
// as it will break esbuild
|
|
57
|
+
if (isSubdir(flowershowDir, contentDir)) {
|
|
58
|
+
log(`Provided content directory: ${contentDir}`);
|
|
59
|
+
log(`Provided Flowershow template installation directory: ${flowershowDir}`);
|
|
60
|
+
error(`You can't install the Flowershow template inside your content folder.`);
|
|
61
|
+
exit(1);
|
|
62
|
+
}
|
|
63
|
+
const assetFolderChoices = fs
|
|
64
|
+
.readdirSync(contentDir, { withFileTypes: true })
|
|
65
|
+
.filter((d) => d.isDirectory())
|
|
66
|
+
.map((d) => ({ name: d.name, value: d.name }));
|
|
67
|
+
let assetsFolder;
|
|
68
|
+
if (!assetFolderChoices.length) {
|
|
69
|
+
const { foldersAction } = await inquirer.prompt([
|
|
70
|
+
{
|
|
71
|
+
name: "foldersAction",
|
|
72
|
+
type: "list",
|
|
73
|
+
message: "There are no subfolders in your content folder, that could be used as assets folder",
|
|
74
|
+
choices: [
|
|
75
|
+
{ name: "I don't need assets folder", value: "none" },
|
|
76
|
+
{ name: "Cancel", value: null },
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
]);
|
|
80
|
+
assetsFolder = foldersAction;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
const { assets } = await inquirer.prompt([
|
|
84
|
+
{
|
|
85
|
+
name: "assets",
|
|
86
|
+
type: "list",
|
|
87
|
+
message: "Select a folder with your assets (attachments)",
|
|
88
|
+
choices: [
|
|
89
|
+
...assetFolderChoices,
|
|
90
|
+
new inquirer.Separator(),
|
|
91
|
+
{ name: "I don't need assets folder", value: "none" },
|
|
92
|
+
{ name: "Cancel", value: null },
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
]);
|
|
96
|
+
assetsFolder = assets;
|
|
97
|
+
}
|
|
98
|
+
if (!assetsFolder) {
|
|
99
|
+
exit(0);
|
|
100
|
+
}
|
|
101
|
+
// install flowershow template
|
|
102
|
+
// // if there is no index.md file, create one
|
|
103
|
+
if (!fs.existsSync(`${contentPath}/index.md`)) {
|
|
104
|
+
info(`No index.md file found in ${contentDir}. Flowershow will create one for you.`);
|
|
105
|
+
const homePageContent = "# Welcome to my Flowershow site!";
|
|
106
|
+
// eslint-disable-next-line no-unused-vars
|
|
107
|
+
fs.writeFile(`${contentPath}/index.md`, homePageContent, { flag: "a" }, (err) => { } // eslint-disable-line @typescript-eslint/no-empty-function
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
// if there is a config.js file from older flowershow, change its extension.
|
|
111
|
+
if (fs.existsSync(`${contentPath}/config.js`)) {
|
|
112
|
+
fs.rename(`${contentPath}/config.js`, `${contentPath}/config.mjs`, (err) => {
|
|
113
|
+
if (err)
|
|
114
|
+
info(`Failed to rename ${contentPath}/config.js file`);
|
|
115
|
+
info(`Renamed config.js file in ${contentDir} to config.mjs`);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
// // if there is no config.mjs file, create one
|
|
119
|
+
if (!fs.existsSync(`${contentPath}/config.mjs`)) {
|
|
120
|
+
info(`No config.mjs file found in ${contentDir}. Flowershow will create one for you.`);
|
|
121
|
+
fs.writeFile(`${contentPath}/config.mjs`, "const config = {};\nexport default config;", { flag: "a" }, (err) => { } // eslint-disable-line @typescript-eslint/no-empty-function
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
// create flowershow template
|
|
125
|
+
logWithSpinner({
|
|
126
|
+
symbol: "🌷",
|
|
127
|
+
msg: `Creating Flowershow template in ${chalk.magenta(flowershowDir)}`,
|
|
128
|
+
});
|
|
129
|
+
try {
|
|
130
|
+
if (existsAction === "overwrite") {
|
|
131
|
+
fs.rmSync(flowershowDir, { recursive: true, force: true });
|
|
132
|
+
}
|
|
133
|
+
const emitter = degit(templateRepo);
|
|
134
|
+
await emitter.clone(flowershowDir);
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
error(`Failed to clone Flowershow template into ${flowershowDir}. This may be a problem with Flowershow. Please let us know about it by submitting an issue: https://github.com/flowershow/flowershow/issues.`);
|
|
138
|
+
log(err);
|
|
139
|
+
exit(1);
|
|
140
|
+
}
|
|
141
|
+
// update content and assets symlinks
|
|
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);
|
|
164
|
+
}
|
|
165
|
+
// install flowershow dependencies
|
|
166
|
+
logWithSpinner({ symbol: "🌸", msg: `Installing Flowershow dependencies` });
|
|
167
|
+
try {
|
|
168
|
+
const subprocess = execa("npm", ["install"], {
|
|
169
|
+
cwd: flowershowDir,
|
|
170
|
+
});
|
|
171
|
+
process.on("SIGINT", () => {
|
|
172
|
+
subprocess.kill("SIGINT");
|
|
173
|
+
});
|
|
174
|
+
const { stdout, stderr } = await subprocess;
|
|
175
|
+
log(stdout);
|
|
176
|
+
log(stderr);
|
|
177
|
+
stopSpinner();
|
|
178
|
+
success("Successfully installed Flowershow!");
|
|
179
|
+
}
|
|
180
|
+
catch (err) {
|
|
181
|
+
error(`Failed to install Flowershow dependencies: ${err.message}`);
|
|
182
|
+
exit(err.exitCode);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { execa } from "execa";
|
|
4
|
+
import { exit, error } from "./utils/index.js";
|
|
5
|
+
import { FLOWERSHOW_FOLDER_NAME } from "./const.js";
|
|
6
|
+
export default async function build(dir) {
|
|
7
|
+
const flowershowDir = path.resolve(dir, FLOWERSHOW_FOLDER_NAME);
|
|
8
|
+
// check if flowershow is installed
|
|
9
|
+
if (!fs.existsSync(flowershowDir)) {
|
|
10
|
+
error(`Directory ${flowershowDir} does not exist.`);
|
|
11
|
+
exit(1);
|
|
12
|
+
}
|
|
13
|
+
const subprocess = execa("npm", ["run", "build"], { cwd: flowershowDir });
|
|
14
|
+
subprocess.stdout.pipe(process.stdout);
|
|
15
|
+
process.on("SIGINT", () => {
|
|
16
|
+
subprocess.kill("SIGINT");
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { execa } from "execa";
|
|
3
|
+
import { FLOWERSHOW_FOLDER_NAME } from "./const.js";
|
|
4
|
+
export default async function buildExport(dir) {
|
|
5
|
+
const flowershowDir = path.resolve(dir, FLOWERSHOW_FOLDER_NAME);
|
|
6
|
+
const subprocess = execa("npm", ["run", "export"], { cwd: flowershowDir });
|
|
7
|
+
subprocess.stdout.pipe(process.stdout);
|
|
8
|
+
process.on("SIGINT", () => {
|
|
9
|
+
subprocess.kill("SIGINT");
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const FLOWERSHOW_FOLDER_NAME = ".flowershow";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import inquirer from "inquirer";
|
|
4
|
+
import Installer from "./Installer.js";
|
|
5
|
+
import { error, exit } from "./utils/index.js";
|
|
6
|
+
export default async function install(dir) {
|
|
7
|
+
const currentDir = process.cwd();
|
|
8
|
+
const inCurrentDir = dir === ".";
|
|
9
|
+
if (inCurrentDir) {
|
|
10
|
+
const { ok } = await inquirer.prompt([
|
|
11
|
+
{
|
|
12
|
+
name: "ok",
|
|
13
|
+
type: "confirm",
|
|
14
|
+
message: "Create Flowershow project in current directory?",
|
|
15
|
+
},
|
|
16
|
+
]);
|
|
17
|
+
if (!ok) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const targetDir = path.resolve(dir);
|
|
22
|
+
if (!fs.existsSync(targetDir)) {
|
|
23
|
+
error(`Directory ${targetDir} does not exist.`);
|
|
24
|
+
exit(1);
|
|
25
|
+
}
|
|
26
|
+
const installer = new Installer(currentDir, targetDir);
|
|
27
|
+
await installer.install();
|
|
28
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { execa } from "execa";
|
|
4
|
+
import { exit, error } from "./utils/index.js";
|
|
5
|
+
import { FLOWERSHOW_FOLDER_NAME } from "./const.js";
|
|
6
|
+
export default async function preview(dir) {
|
|
7
|
+
const flowershowDir = path.resolve(dir, FLOWERSHOW_FOLDER_NAME);
|
|
8
|
+
// check if flowershow is installed
|
|
9
|
+
if (!fs.existsSync(flowershowDir)) {
|
|
10
|
+
error(`Directory ${flowershowDir} does not exist.`);
|
|
11
|
+
exit(1);
|
|
12
|
+
}
|
|
13
|
+
const subprocess = execa("npm", ["run", "dev"], { cwd: flowershowDir });
|
|
14
|
+
subprocess.stdout.pipe(process.stdout);
|
|
15
|
+
process.on("SIGINT", () => {
|
|
16
|
+
subprocess.kill("SIGINT");
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
const log = console.log;
|
|
3
|
+
export default function publish() {
|
|
4
|
+
log(chalk.redBright.bold("Command under construction...\n"));
|
|
5
|
+
log(chalk.blue("Check " +
|
|
6
|
+
chalk.green.underline("https://flowershow.app") +
|
|
7
|
+
" to learn more about Flowershow development stage and subscribe to get notified when it's ready!"));
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
const log = console.log;
|
|
3
|
+
export default function upgrade() {
|
|
4
|
+
log(chalk.redBright.bold("Command under construction...\n"));
|
|
5
|
+
log(chalk.blue("Check " +
|
|
6
|
+
chalk.green.underline("https://flowershow.app") +
|
|
7
|
+
" to learn more about Flowershow development stage and subscribe to get notified when it's ready!"));
|
|
8
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { error, info, log, success, warn } from "./logger.js";
|
|
2
|
+
export { exit } from "./exit.js";
|
|
3
|
+
export { isSubdir } from "./isSubdir.js";
|
|
4
|
+
export { sendEvent } from "./sendEvent.js";
|
|
5
|
+
export { logWithSpinner, stopSpinner, pauseSpinner, resumeSpinner, } from "./spinner.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
export const log = (msg = "") => {
|
|
3
|
+
console.log(msg);
|
|
4
|
+
};
|
|
5
|
+
export const info = (msg) => {
|
|
6
|
+
console.log(`${chalk.bgBlueBright.black(" INFO ")} ${msg}`);
|
|
7
|
+
};
|
|
8
|
+
export const error = (msg) => {
|
|
9
|
+
console.error(`\n${chalk.bgRed(" ERROR ")} ${chalk.red(msg)}`);
|
|
10
|
+
if (msg instanceof Error) {
|
|
11
|
+
console.error(msg.stack);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export const success = (msg) => {
|
|
15
|
+
console.log(`${chalk.blue("🎊")} ${msg}`);
|
|
16
|
+
};
|
|
17
|
+
export const warn = (msg) => {
|
|
18
|
+
console.log(`${chalk.red("⚠")} ${msg}`);
|
|
19
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import ora from "ora";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
const spinner = ora({ color: "magenta" });
|
|
4
|
+
let lastMsg = null;
|
|
5
|
+
let isPaused = false;
|
|
6
|
+
export const logWithSpinner = ({ msg, symbol }) => {
|
|
7
|
+
if (!symbol) {
|
|
8
|
+
symbol = chalk.green("✔");
|
|
9
|
+
}
|
|
10
|
+
if (lastMsg) {
|
|
11
|
+
spinner.stopAndPersist({
|
|
12
|
+
symbol: lastMsg.symbol,
|
|
13
|
+
text: lastMsg.text,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
spinner.text = " " + msg;
|
|
17
|
+
lastMsg = {
|
|
18
|
+
symbol: symbol + " ",
|
|
19
|
+
text: msg,
|
|
20
|
+
};
|
|
21
|
+
spinner.start();
|
|
22
|
+
};
|
|
23
|
+
export const stopSpinner = () => {
|
|
24
|
+
if (!spinner.isSpinning) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (lastMsg) {
|
|
28
|
+
spinner.stopAndPersist({
|
|
29
|
+
symbol: lastMsg.symbol,
|
|
30
|
+
text: lastMsg.text,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
spinner.stop();
|
|
35
|
+
}
|
|
36
|
+
lastMsg = null;
|
|
37
|
+
};
|
|
38
|
+
export const pauseSpinner = () => {
|
|
39
|
+
if (spinner.isSpinning) {
|
|
40
|
+
spinner.stop();
|
|
41
|
+
isPaused = true;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
export const resumeSpinner = () => {
|
|
45
|
+
if (isPaused) {
|
|
46
|
+
spinner.start();
|
|
47
|
+
isPaused = false;
|
|
48
|
+
}
|
|
49
|
+
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flowershow",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Publish your digital garden",
|
|
5
5
|
"bin": {
|
|
6
|
-
"flowershow": "
|
|
6
|
+
"flowershow": "dist/bin/cli.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsc --project tsconfig.lib.json",
|
|
10
|
+
"lint": "eslint --fix .",
|
|
11
|
+
"e2e": "mkdir -p coverage/cli-e2e && e2e/bats-core/bin/bats e2e/test.bats -p --report-formatter pretty -o coverage/cli-e2e --verbose-run"
|
|
7
12
|
},
|
|
8
13
|
"repository": {
|
|
9
14
|
"type": "git",
|
|
@@ -11,7 +16,7 @@
|
|
|
11
16
|
"directory": "packages/cli"
|
|
12
17
|
},
|
|
13
18
|
"files": [
|
|
14
|
-
"
|
|
19
|
+
"./dist"
|
|
15
20
|
],
|
|
16
21
|
"keywords": [
|
|
17
22
|
"flowershow",
|
|
@@ -39,6 +44,12 @@
|
|
|
39
44
|
"engines": {
|
|
40
45
|
"node": ">=16.3.0"
|
|
41
46
|
},
|
|
42
|
-
"
|
|
43
|
-
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/degit": "^2.8.3",
|
|
49
|
+
"@types/inquirer": "^9.0.3",
|
|
50
|
+
"@types/node": "^20.3.1",
|
|
51
|
+
"@types/universal-analytics": "^0.4.5",
|
|
52
|
+
"tsc": "^2.0.4",
|
|
53
|
+
"typescript": "^5.1.3"
|
|
54
|
+
}
|
|
44
55
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# flowershow
|
|
2
|
-
|
|
3
|
-
## 0.1.8
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Adjust the CLI Installer after migrating Flowershow template to datopian/flowershow-template.
|
|
8
|
-
|
|
9
|
-
## 0.1.7
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
- Rename [...slug].tsx to [[...slug]].tsx at installation, so that user can still define their own home pages using MD files.
|
|
14
|
-
|
|
15
|
-
## 0.1.6
|
|
16
|
-
|
|
17
|
-
### Patch Changes
|
|
18
|
-
|
|
19
|
-
- f136048: Remove `pages/index.tsx` file from the copied Flowershow template, to allow users to set their own home page with MD file.
|
|
20
|
-
|
|
21
|
-
## 0.1.5
|
|
22
|
-
|
|
23
|
-
### Patch Changes
|
|
24
|
-
|
|
25
|
-
- Replace config.js with config.mjs
|
|
26
|
-
|
|
27
|
-
## 0.1.4
|
|
28
|
-
|
|
29
|
-
### Patch Changes
|
|
30
|
-
|
|
31
|
-
- Fix: incorrect `config.js` file created by the CLI
|
|
32
|
-
|
|
33
|
-
## 0.1.3
|
|
34
|
-
|
|
35
|
-
### Patch Changes
|
|
36
|
-
|
|
37
|
-
- Remove unneeded dev files from cloned template.
|
|
38
|
-
|
|
39
|
-
## 0.1.0
|
|
40
|
-
|
|
41
|
-
### Minor Changes
|
|
42
|
-
|
|
43
|
-
- 93b7911: Switch from JS to TS.
|
|
44
|
-
|
|
45
|
-
## 0.0.11
|
|
46
|
-
|
|
47
|
-
### Patch Changes
|
|
48
|
-
|
|
49
|
-
- Basic anonymous telemetry (OS, Flowershow version and command being run).
|
|
50
|
-
|
|
51
|
-
## 0.0.10
|
|
52
|
-
|
|
53
|
-
### Patch Changes
|
|
54
|
-
|
|
55
|
-
- Rename `flowershow build-static` to `flowershow export`.
|
|
56
|
-
|
|
57
|
-
## 0.0.9
|
|
58
|
-
|
|
59
|
-
### Patch Changes
|
|
60
|
-
|
|
61
|
-
- CLI support for Windows. Symlink files removed from the template.
|
|
62
|
-
- Add information about missing index.md and/or config.js files that the CLI will automatically create for the user.
|
|
63
|
-
|
|
64
|
-
## 0.0.8
|
|
65
|
-
|
|
66
|
-
### Patch Changes
|
|
67
|
-
|
|
68
|
-
- Disallow installing the template inside the content folder.
|
/package/{src → dist}/bin/cli.js
RENAMED
|
File without changes
|
/package/{src → dist}/index.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|