flowershow 0.0.6 → 0.0.8
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/.babelrc +3 -0
- package/.eslintrc.json +3 -0
- package/CHANGELOG.md +7 -0
- package/LICENSE +21 -0
- package/jest.config.js +16 -0
- package/package.json +4 -8
- package/project.json +41 -0
- package/src/bin/cli.js +102 -0
- package/src/index.js +1 -0
- package/src/lib/Installer.js +213 -0
- package/src/lib/build.js +19 -0
- package/src/lib/buildStatic.js +12 -0
- package/src/lib/const.js +1 -0
- package/{lib → src/lib}/install.js +10 -12
- package/src/lib/preview.js +20 -0
- package/src/lib/publish.js +14 -0
- package/src/lib/upgrade.js +14 -0
- package/{lib → src/lib}/utils/exit.js +1 -1
- package/src/lib/utils/index.js +9 -0
- package/src/lib/utils/isSubdir.js +7 -0
- package/src/lib/utils/logger.js +24 -0
- package/{lib → src/lib}/utils/spinner.js +25 -25
- package/tsconfig.json +16 -0
- package/tsconfig.lib.json +17 -0
- package/tsconfig.spec.json +20 -0
- package/bin/flowershow.js +0 -83
- package/lib/Installer.js +0 -167
- package/lib/build.js +0 -20
- package/lib/buildStatic.js +0 -15
- package/lib/const.js +0 -1
- package/lib/preview.js +0 -21
- package/lib/publish.js +0 -12
- package/lib/upgrade.js +0 -12
- package/lib/utils/index.js +0 -3
- package/lib/utils/logger.js +0 -24
package/.babelrc
ADDED
package/.eslintrc.json
ADDED
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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.
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
export default {
|
|
3
|
+
displayName: "cli",
|
|
4
|
+
preset: "../../jest.preset.js",
|
|
5
|
+
globals: {
|
|
6
|
+
"ts-jest": {
|
|
7
|
+
tsconfig: "<rootDir>/tsconfig.spec.json",
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
testEnvironment: "node",
|
|
11
|
+
transform: {
|
|
12
|
+
"^.+\\.[tj]sx?$": "ts-jest",
|
|
13
|
+
},
|
|
14
|
+
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
|
|
15
|
+
coverageDirectory: "../../coverage/packages/cli",
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flowershow",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Publish your digital garden",
|
|
5
5
|
"bin": {
|
|
6
|
-
"flowershow": "bin/
|
|
6
|
+
"flowershow": "src/bin/cli.js"
|
|
7
7
|
},
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -14,9 +14,6 @@
|
|
|
14
14
|
"flowershow",
|
|
15
15
|
"cli"
|
|
16
16
|
],
|
|
17
|
-
"scripts": {
|
|
18
|
-
"test": "./e2e/bats/bin/bats ./e2e/test.bats --verbose-run"
|
|
19
|
-
},
|
|
20
17
|
"author": "Rufus Pollock",
|
|
21
18
|
"license": "MIT",
|
|
22
19
|
"bugs": {
|
|
@@ -32,11 +29,10 @@
|
|
|
32
29
|
"degit": "^2.8.4",
|
|
33
30
|
"execa": "^6.1.0",
|
|
34
31
|
"inquirer": "^9.1.1",
|
|
35
|
-
"ora": "^6.1.2"
|
|
36
|
-
"validate-npm-package-name": "^4.0.0"
|
|
32
|
+
"ora": "^6.1.2"
|
|
37
33
|
},
|
|
38
34
|
"type": "module",
|
|
39
35
|
"engines": {
|
|
40
36
|
"node": ">=12.2.0 || >=14.13.0"
|
|
41
37
|
}
|
|
42
|
-
}
|
|
38
|
+
}
|
package/project.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cli",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "packages/cli/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"targets": {
|
|
7
|
+
"lint": {
|
|
8
|
+
"executor": "@nrwl/linter:eslint",
|
|
9
|
+
"options": {
|
|
10
|
+
"fix": true,
|
|
11
|
+
"lintFilePatterns": ["packages/cli/**/*.js"]
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"test": {
|
|
15
|
+
"executor": "@nrwl/jest:jest",
|
|
16
|
+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
17
|
+
"options": {
|
|
18
|
+
"jestConfig": "packages/cli/jest.config.js",
|
|
19
|
+
"passWithNoTests": true
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"e2e": {
|
|
23
|
+
"executor": "nx:run-commands",
|
|
24
|
+
"options": {
|
|
25
|
+
"commands": [
|
|
26
|
+
"mkdir -p coverage/packages/cli-e2e",
|
|
27
|
+
"packages/cli/src/e2e/bats/bin/bats packages/cli/src/e2e/test.bats -p --report-formatter pretty -o coverage/packages/cli-e2e --verbose-run"
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"parallel": false,
|
|
31
|
+
"inputs": [
|
|
32
|
+
"default",
|
|
33
|
+
"^production",
|
|
34
|
+
"{projectRoot}/src/e2e/.env",
|
|
35
|
+
{ "env": "NETLIFY_TOKEN" }
|
|
36
|
+
],
|
|
37
|
+
"outputs": ["coverage/packages/cli-e2e"]
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"tags": []
|
|
41
|
+
}
|
package/src/bin/cli.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
const require = createRequire(import.meta.url);
|
|
4
|
+
import { warn } from "../lib/utils/index.js";
|
|
5
|
+
|
|
6
|
+
import os from "os";
|
|
7
|
+
|
|
8
|
+
if (os.platform() === "win32") {
|
|
9
|
+
warn(
|
|
10
|
+
"This may not work as expected. You're trying to run Flowreshow CLI on Windows, which is not supported yet..."
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// TODO check current vs required node version (package.json engines)
|
|
15
|
+
// const requiredNodeVersion = require("../package.json").engines.node;
|
|
16
|
+
|
|
17
|
+
import { Command } from "commander";
|
|
18
|
+
|
|
19
|
+
const program = new Command();
|
|
20
|
+
|
|
21
|
+
program
|
|
22
|
+
.description(
|
|
23
|
+
"CLI tool for creating, publishing and upgrading Flowershow apps"
|
|
24
|
+
)
|
|
25
|
+
.version(require("../../package.json").version)
|
|
26
|
+
.usage("<command> [options]");
|
|
27
|
+
|
|
28
|
+
// choose template
|
|
29
|
+
program
|
|
30
|
+
.command("install")
|
|
31
|
+
.description("install Flowershow template in target directory")
|
|
32
|
+
.argument(
|
|
33
|
+
"[target-dir]",
|
|
34
|
+
"Path to the folder where you want Flowershow template to be installed",
|
|
35
|
+
"."
|
|
36
|
+
)
|
|
37
|
+
// .option('-t, --template [template-name]', 'Flowershow template name to use', 'default')
|
|
38
|
+
.action(async (targetDir, options) => {
|
|
39
|
+
const { default: install } = await import("../lib/install.js");
|
|
40
|
+
install(targetDir, options);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
program
|
|
44
|
+
.command("build")
|
|
45
|
+
.description("build Flowershow website")
|
|
46
|
+
.argument(
|
|
47
|
+
"[project-dir]",
|
|
48
|
+
"Path to the folder where Flowershow template is installed (root folder of .flowershow)",
|
|
49
|
+
"."
|
|
50
|
+
)
|
|
51
|
+
.action(async (projectPath) => {
|
|
52
|
+
const { default: build } = await import("../lib/build.js");
|
|
53
|
+
build(projectPath);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
program
|
|
57
|
+
.command("build-static")
|
|
58
|
+
.description("build static Flowershow website")
|
|
59
|
+
.argument(
|
|
60
|
+
"[project-dir]",
|
|
61
|
+
"Path to the folder where Flowershow template is installed (root folder of .flowershow)",
|
|
62
|
+
"."
|
|
63
|
+
)
|
|
64
|
+
.action(async (projectPath) => {
|
|
65
|
+
const { default: buildStatic } = await import("../lib/buildStatic.js");
|
|
66
|
+
buildStatic(projectPath);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
program
|
|
70
|
+
.command("preview")
|
|
71
|
+
.description("preview your Flowershow site")
|
|
72
|
+
.argument(
|
|
73
|
+
"[project-dir]",
|
|
74
|
+
"Path to the folder where Flowershow template is installed (root folder of .flowershow)",
|
|
75
|
+
"."
|
|
76
|
+
)
|
|
77
|
+
.action(async (projectPath) => {
|
|
78
|
+
const { default: preview } = await import("../lib/preview.js");
|
|
79
|
+
preview(projectPath);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// TBD
|
|
83
|
+
program
|
|
84
|
+
.command("publish")
|
|
85
|
+
.description("publish files or directories")
|
|
86
|
+
.argument("[path]", "path to a file or a directory", ".")
|
|
87
|
+
.option("-g, --glob <pattern>", "glob pattern")
|
|
88
|
+
.action(async () => {
|
|
89
|
+
const { default: publish } = await import("../lib/publish.js");
|
|
90
|
+
publish();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// TBD
|
|
94
|
+
program
|
|
95
|
+
.command("upgrade")
|
|
96
|
+
.description("upgrade your Flowershow template to the latest version")
|
|
97
|
+
.action(async () => {
|
|
98
|
+
const { default: upgrade } = await import("../lib/upgrade.js");
|
|
99
|
+
upgrade();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
program.parse();
|
package/src/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// export * from './lib/cli';
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import chalk from "chalk";
|
|
7
|
+
import degit from "degit";
|
|
8
|
+
import { execa } from "execa";
|
|
9
|
+
import inquirer from "inquirer";
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
exit,
|
|
13
|
+
error,
|
|
14
|
+
log,
|
|
15
|
+
success,
|
|
16
|
+
logWithSpinner,
|
|
17
|
+
stopSpinner,
|
|
18
|
+
isSubdir,
|
|
19
|
+
} from "./utils/index.js";
|
|
20
|
+
|
|
21
|
+
import { FLOWERSHOW_FOLDER_NAME } from "./const.js";
|
|
22
|
+
|
|
23
|
+
export default class Creator {
|
|
24
|
+
constructor(context, targetDir) {
|
|
25
|
+
this.context = context;
|
|
26
|
+
this.targetDir = targetDir;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get templateRepo() {
|
|
30
|
+
const flowershowRepo = require("../../package.json").repository.url.replace(
|
|
31
|
+
"git+",
|
|
32
|
+
""
|
|
33
|
+
);
|
|
34
|
+
return `${flowershowRepo}/packages/template`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async install() {
|
|
38
|
+
const { context, targetDir, templateRepo } = this;
|
|
39
|
+
const flowershowDir = path.resolve(targetDir, FLOWERSHOW_FOLDER_NAME);
|
|
40
|
+
|
|
41
|
+
let existsAction;
|
|
42
|
+
if (fs.existsSync(flowershowDir)) {
|
|
43
|
+
let { action } = await inquirer.prompt([
|
|
44
|
+
{
|
|
45
|
+
name: "action",
|
|
46
|
+
type: "list",
|
|
47
|
+
message: `Flowershow template is already installed in directory ${chalk.magenta(
|
|
48
|
+
targetDir
|
|
49
|
+
)}. What do you want to do?:`,
|
|
50
|
+
choices: [
|
|
51
|
+
{ name: "Overwrite", value: "overwrite" },
|
|
52
|
+
// { name: 'Merge', value: 'merge' },
|
|
53
|
+
{ name: "Cancel", value: null },
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
]);
|
|
57
|
+
|
|
58
|
+
if (!action) {
|
|
59
|
+
exit(0);
|
|
60
|
+
}
|
|
61
|
+
existsAction = action;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let { contentPath } = await inquirer.prompt([
|
|
65
|
+
{
|
|
66
|
+
name: "contentPath",
|
|
67
|
+
type: "input",
|
|
68
|
+
message: "Path to the folder with your markdown files",
|
|
69
|
+
validate(input) {
|
|
70
|
+
const contentDir = path.resolve(context, input);
|
|
71
|
+
if (!fs.existsSync(contentDir)) {
|
|
72
|
+
error(`Directory ${contentDir} does not exist.`);
|
|
73
|
+
exit(1);
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
]);
|
|
79
|
+
|
|
80
|
+
const contentDir = path.resolve(context, contentPath);
|
|
81
|
+
|
|
82
|
+
// don't allow for installing the template anywhere within the content folder
|
|
83
|
+
// as it will break esbuild
|
|
84
|
+
if (isSubdir(flowershowDir, contentDir)) {
|
|
85
|
+
log(`Provided content directory: ${contentDir}`);
|
|
86
|
+
log(
|
|
87
|
+
`Provided Flowershow template installation directory: ${flowershowDir}`
|
|
88
|
+
);
|
|
89
|
+
error(
|
|
90
|
+
`You can't install the Flowershow template inside your content folder.`
|
|
91
|
+
);
|
|
92
|
+
exit(1);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const assetFolderChoices = fs
|
|
96
|
+
.readdirSync(contentDir, { withFileTypes: true })
|
|
97
|
+
.filter((d) => d.isDirectory())
|
|
98
|
+
.map((d) => ({ name: d.name, value: d.name }));
|
|
99
|
+
|
|
100
|
+
let assetsFolder = "none";
|
|
101
|
+
|
|
102
|
+
if (!assetFolderChoices.length) {
|
|
103
|
+
const { foldersAction } = await inquirer.prompt([
|
|
104
|
+
{
|
|
105
|
+
name: "foldersAction",
|
|
106
|
+
type: "list",
|
|
107
|
+
message:
|
|
108
|
+
"There are no subfolders in your content folder, that could be used as assets folder",
|
|
109
|
+
choices: [
|
|
110
|
+
{ name: "I don't need assets folder", value: "none" },
|
|
111
|
+
{ name: "Cancel", value: null },
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
]);
|
|
115
|
+
|
|
116
|
+
assetsFolder = foldersAction;
|
|
117
|
+
} else {
|
|
118
|
+
const { assets } = await inquirer.prompt([
|
|
119
|
+
{
|
|
120
|
+
name: "assets",
|
|
121
|
+
type: "list",
|
|
122
|
+
message: "Select a folder with your assets (attachments)",
|
|
123
|
+
choices: [
|
|
124
|
+
...assetFolderChoices,
|
|
125
|
+
new inquirer.Separator(),
|
|
126
|
+
{ name: "I don't need assets folder", value: "none" },
|
|
127
|
+
{ name: "Cancel", value: null },
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
]);
|
|
131
|
+
|
|
132
|
+
assetsFolder = assets;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (!assetsFolder) {
|
|
136
|
+
exit(0);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// install flowershow template
|
|
140
|
+
logWithSpinner({
|
|
141
|
+
symbol: "🌷",
|
|
142
|
+
msg: `Installing Flowershow template in ${chalk.magenta(
|
|
143
|
+
flowershowDir
|
|
144
|
+
)}...`,
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
if (existsAction === "overwrite") {
|
|
148
|
+
fs.rmSync(flowershowDir, { recursive: true, force: true });
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
try {
|
|
152
|
+
const emitter = degit(templateRepo);
|
|
153
|
+
await emitter.clone(flowershowDir);
|
|
154
|
+
} catch {
|
|
155
|
+
error(`Failed to install Flowershow template in ${flowershowDir}.`);
|
|
156
|
+
exit(1);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// update content and assets symlinks
|
|
160
|
+
fs.unlinkSync(`${flowershowDir}/content`);
|
|
161
|
+
fs.symlinkSync(contentDir, `${flowershowDir}/content`);
|
|
162
|
+
|
|
163
|
+
fs.unlinkSync(`${flowershowDir}/public/assets`);
|
|
164
|
+
if (assetsFolder !== "none") {
|
|
165
|
+
fs.symlinkSync(
|
|
166
|
+
path.resolve(contentDir, assetsFolder),
|
|
167
|
+
`${flowershowDir}/public/${assetsFolder}`
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// // if there is no index.md file, create one
|
|
172
|
+
if (!fs.existsSync(`${contentPath}/index.md`)) {
|
|
173
|
+
const homePageContent = "# Welcome to my Flowershow site!";
|
|
174
|
+
fs.writeFile(
|
|
175
|
+
`${contentPath}/index.md`,
|
|
176
|
+
homePageContent,
|
|
177
|
+
{ flag: "a" },
|
|
178
|
+
(err) => {} // eslint-disable-line no-unused-vars
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// // if there is no config.js file, create one
|
|
183
|
+
if (!fs.existsSync(`${contentPath}/config.js`)) {
|
|
184
|
+
fs.writeFile(
|
|
185
|
+
`${contentPath}/config.js`,
|
|
186
|
+
"{}",
|
|
187
|
+
{ flag: "a" },
|
|
188
|
+
(err) => {} // eslint-disable-line no-unused-vars
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// install flowershow dependencies
|
|
193
|
+
logWithSpinner({
|
|
194
|
+
symbol: "🌸",
|
|
195
|
+
msg: `Installing Flowershow dependencies...`,
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
try {
|
|
199
|
+
// TODO this can be removed after monorepo has been set up correctly
|
|
200
|
+
await execa("npm", ["set-script", "prepare", ""], { cwd: flowershowDir });
|
|
201
|
+
const { stdout, stderr } = await execa("npm", ["install"], {
|
|
202
|
+
cwd: flowershowDir,
|
|
203
|
+
});
|
|
204
|
+
log(stdout);
|
|
205
|
+
log(stderr);
|
|
206
|
+
stopSpinner();
|
|
207
|
+
success("Successfuly installed Flowershow!");
|
|
208
|
+
} catch (err) {
|
|
209
|
+
error(`Installing dependencies failed: ${err.message}`);
|
|
210
|
+
exit(err.exitCode);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
package/src/lib/build.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { execa } from "execa";
|
|
4
|
+
|
|
5
|
+
import { exit, error } from "./utils/index.js";
|
|
6
|
+
import { FLOWERSHOW_FOLDER_NAME } from "./const.js";
|
|
7
|
+
|
|
8
|
+
export default async function build(dir) {
|
|
9
|
+
const flowershowDir = path.resolve(dir, FLOWERSHOW_FOLDER_NAME);
|
|
10
|
+
|
|
11
|
+
// check if flowershow is installed
|
|
12
|
+
if (!fs.existsSync(flowershowDir)) {
|
|
13
|
+
error(`Directory ${flowershowDir} does not exist.`);
|
|
14
|
+
exit(1);
|
|
15
|
+
}
|
|
16
|
+
const subprocess = execa("npm", ["run", "build"], { cwd: flowershowDir });
|
|
17
|
+
|
|
18
|
+
subprocess.stdout.pipe(process.stdout);
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { execa } from "execa";
|
|
3
|
+
|
|
4
|
+
import { FLOWERSHOW_FOLDER_NAME } from "./const.js";
|
|
5
|
+
|
|
6
|
+
export default async function buildStatic(dir) {
|
|
7
|
+
const flowershowDir = path.resolve(dir, FLOWERSHOW_FOLDER_NAME);
|
|
8
|
+
|
|
9
|
+
const subprocess = execa("npm", ["run", "export"], { cwd: flowershowDir });
|
|
10
|
+
|
|
11
|
+
subprocess.stdout.pipe(process.stdout);
|
|
12
|
+
}
|
package/src/lib/const.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const FLOWERSHOW_FOLDER_NAME = ".flowershow";
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import path from
|
|
3
|
-
import
|
|
4
|
-
import inquirer from 'inquirer';
|
|
5
|
-
|
|
6
|
-
import Installer from './Installer.js';
|
|
7
|
-
import { error, log, exit } from './utils/index.js';
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import inquirer from "inquirer";
|
|
8
4
|
|
|
5
|
+
import Installer from "./Installer.js";
|
|
6
|
+
import { error, exit } from "./utils/index.js";
|
|
9
7
|
|
|
10
8
|
export default async function install(dir, options) {
|
|
11
9
|
const currentDir = process.cwd();
|
|
12
|
-
const inCurrentDir = dir ===
|
|
10
|
+
const inCurrentDir = dir === ".";
|
|
13
11
|
|
|
14
12
|
if (inCurrentDir) {
|
|
15
13
|
const { ok } = await inquirer.prompt([
|
|
16
14
|
{
|
|
17
15
|
name: "ok",
|
|
18
16
|
type: "confirm",
|
|
19
|
-
message: "Create Flowershow project in current directory?"
|
|
20
|
-
}
|
|
21
|
-
])
|
|
17
|
+
message: "Create Flowershow project in current directory?",
|
|
18
|
+
},
|
|
19
|
+
]);
|
|
22
20
|
if (!ok) {
|
|
23
|
-
return
|
|
21
|
+
return;
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { execa } from "execa";
|
|
4
|
+
|
|
5
|
+
import { exit, error } from "./utils/index.js";
|
|
6
|
+
|
|
7
|
+
import { FLOWERSHOW_FOLDER_NAME } from "./const.js";
|
|
8
|
+
|
|
9
|
+
export default async function preview(dir) {
|
|
10
|
+
const flowershowDir = path.resolve(dir, FLOWERSHOW_FOLDER_NAME);
|
|
11
|
+
|
|
12
|
+
// check if flowershow is installed
|
|
13
|
+
if (!fs.existsSync(flowershowDir)) {
|
|
14
|
+
error(`Directory ${flowershowDir} does not exist.`);
|
|
15
|
+
exit(1);
|
|
16
|
+
}
|
|
17
|
+
const subprocess = execa("npm", ["run", "dev"], { cwd: flowershowDir });
|
|
18
|
+
|
|
19
|
+
subprocess.stdout.pipe(process.stdout);
|
|
20
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
|
|
3
|
+
const log = console.log;
|
|
4
|
+
|
|
5
|
+
export default function publish() {
|
|
6
|
+
log(chalk.redBright.bold("Command under construction...\n"));
|
|
7
|
+
log(
|
|
8
|
+
chalk.blue(
|
|
9
|
+
"Check " +
|
|
10
|
+
chalk.green.underline("https://flowershow.app") +
|
|
11
|
+
" to learn more about Flowershow development stage and subscribe to get notified when it's ready!"
|
|
12
|
+
)
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
|
|
3
|
+
const log = console.log;
|
|
4
|
+
|
|
5
|
+
export default function upgrade() {
|
|
6
|
+
log(chalk.redBright.bold("Command under construction...\n"));
|
|
7
|
+
log(
|
|
8
|
+
chalk.blue(
|
|
9
|
+
"Check " +
|
|
10
|
+
chalk.green.underline("https://flowershow.app") +
|
|
11
|
+
" to learn more about Flowershow development stage and subscribe to get notified when it's ready!"
|
|
12
|
+
)
|
|
13
|
+
);
|
|
14
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
|
|
3
|
+
export const log = (msg = "") => {
|
|
4
|
+
console.log(msg);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const info = (msg) => {
|
|
8
|
+
console.log(`${chalk.bgBlueBright.black(" INFO ")} ${msg}`);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const error = (msg) => {
|
|
12
|
+
console.error(`\n${chalk.bgRed(" ERROR ")} ${chalk.red(msg)}`);
|
|
13
|
+
if (msg instanceof Error) {
|
|
14
|
+
console.error(msg.stack);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const success = (msg) => {
|
|
19
|
+
console.log(`${chalk.blue("🎊")} ${msg}`);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const warn = (msg) => {
|
|
23
|
+
console.log(`${chalk.red("⚠")} ${msg}`);
|
|
24
|
+
};
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import ora from
|
|
2
|
-
import chalk from
|
|
1
|
+
import ora from "ora";
|
|
2
|
+
import chalk from "chalk";
|
|
3
3
|
|
|
4
|
-
const spinner = ora({ color:
|
|
4
|
+
const spinner = ora({ color: "magenta" });
|
|
5
5
|
let lastMsg = null;
|
|
6
|
-
let isPaused = false
|
|
6
|
+
let isPaused = false;
|
|
7
7
|
|
|
8
8
|
export const logWithSpinner = ({ msg, symbol }) => {
|
|
9
9
|
if (!symbol) {
|
|
10
|
-
symbol = chalk.green(
|
|
10
|
+
symbol = chalk.green("✔");
|
|
11
11
|
}
|
|
12
12
|
if (lastMsg) {
|
|
13
13
|
spinner.stopAndPersist({
|
|
14
14
|
symbol: lastMsg.symbol,
|
|
15
|
-
text: lastMsg.text
|
|
16
|
-
})
|
|
15
|
+
text: lastMsg.text,
|
|
16
|
+
});
|
|
17
17
|
}
|
|
18
|
-
spinner.text =
|
|
18
|
+
spinner.text = " " + msg;
|
|
19
19
|
lastMsg = {
|
|
20
|
-
symbol: symbol +
|
|
21
|
-
text: msg
|
|
22
|
-
}
|
|
23
|
-
spinner.start()
|
|
24
|
-
}
|
|
20
|
+
symbol: symbol + " ",
|
|
21
|
+
text: msg,
|
|
22
|
+
};
|
|
23
|
+
spinner.start();
|
|
24
|
+
};
|
|
25
25
|
|
|
26
26
|
export const stopSpinner = () => {
|
|
27
27
|
if (!spinner.isSpinning) {
|
|
28
|
-
return
|
|
28
|
+
return;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
if (lastMsg) {
|
|
32
32
|
spinner.stopAndPersist({
|
|
33
33
|
symbol: lastMsg.symbol,
|
|
34
|
-
text: lastMsg.text
|
|
35
|
-
})
|
|
34
|
+
text: lastMsg.text,
|
|
35
|
+
});
|
|
36
36
|
} else {
|
|
37
|
-
spinner.stop()
|
|
37
|
+
spinner.stop();
|
|
38
38
|
}
|
|
39
|
-
lastMsg = null
|
|
40
|
-
}
|
|
39
|
+
lastMsg = null;
|
|
40
|
+
};
|
|
41
41
|
|
|
42
42
|
export const pauseSpinner = () => {
|
|
43
43
|
if (spinner.isSpinning) {
|
|
44
|
-
spinner.stop()
|
|
45
|
-
isPaused = true
|
|
44
|
+
spinner.stop();
|
|
45
|
+
isPaused = true;
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
};
|
|
48
48
|
|
|
49
49
|
export const resumeSpinner = () => {
|
|
50
50
|
if (isPaused) {
|
|
51
|
-
spinner.start()
|
|
52
|
-
isPaused = false
|
|
51
|
+
spinner.start();
|
|
52
|
+
isPaused = false;
|
|
53
53
|
}
|
|
54
|
-
}
|
|
54
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"outDir": "../../dist/out-tsc",
|
|
6
|
+
"declaration": true,
|
|
7
|
+
"types": ["node"]
|
|
8
|
+
},
|
|
9
|
+
"exclude": [
|
|
10
|
+
"jest.config.ts",
|
|
11
|
+
"**/*.spec.ts",
|
|
12
|
+
"**/*.test.ts",
|
|
13
|
+
"**/*.spec.js",
|
|
14
|
+
"**/*.test.js"
|
|
15
|
+
],
|
|
16
|
+
"include": ["**/*.ts", "**/*.js"]
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../dist/out-tsc",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"types": ["jest", "node"]
|
|
7
|
+
},
|
|
8
|
+
"include": [
|
|
9
|
+
"jest.config.ts",
|
|
10
|
+
"**/*.test.ts",
|
|
11
|
+
"**/*.spec.ts",
|
|
12
|
+
"**/*.test.tsx",
|
|
13
|
+
"**/*.spec.tsx",
|
|
14
|
+
"**/*.test.js",
|
|
15
|
+
"**/*.spec.js",
|
|
16
|
+
"**/*.test.jsx",
|
|
17
|
+
"**/*.spec.jsx",
|
|
18
|
+
"**/*.d.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
package/bin/flowershow.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire } from 'node:module';
|
|
3
|
-
const require = createRequire(import.meta.url);
|
|
4
|
-
import { warn, log } from '../lib/utils/index.js';
|
|
5
|
-
|
|
6
|
-
import os from 'os';
|
|
7
|
-
|
|
8
|
-
if (os.platform() === 'win32') {
|
|
9
|
-
warn("This may not work as expected. You're trying to run Flowreshow CLI on Windows, which is not supported yet...");
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// TODO check current vs required node version (package.json engines)
|
|
13
|
-
// const requiredNodeVersion = require("../package.json").engines.node;
|
|
14
|
-
|
|
15
|
-
import { Command } from "commander";
|
|
16
|
-
|
|
17
|
-
const program = new Command();
|
|
18
|
-
|
|
19
|
-
program
|
|
20
|
-
.description('(Package under development)\nCLI tool for creating, publishing and upgrading Flowershow apps')
|
|
21
|
-
.version(require("../package.json").version)
|
|
22
|
-
.usage('<command> [options]')
|
|
23
|
-
|
|
24
|
-
// choose template
|
|
25
|
-
program
|
|
26
|
-
.command('install')
|
|
27
|
-
.description('install Flowershow template in target directory')
|
|
28
|
-
.argument('[target-dir]', 'Path to the folder where you want Flowershow template to be installed', '.')
|
|
29
|
-
// .option('-t, --template [template-name]', 'Flowershow template name to use', 'default')
|
|
30
|
-
.action(async (targetDir, options) => {
|
|
31
|
-
const { default: install } = await import ('../lib/install.js');
|
|
32
|
-
install(targetDir, options);
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
program
|
|
36
|
-
.command('build')
|
|
37
|
-
.description('build Flowershow website')
|
|
38
|
-
.argument('[project-dir]', 'Path to the folder where Flowershow template is installed (root folder of .flowershow)', '.')
|
|
39
|
-
.action(async (projectPath) => {
|
|
40
|
-
const { default: build } = await import ('../lib/build.js');
|
|
41
|
-
build(projectPath);
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
program
|
|
46
|
-
.command('build-static')
|
|
47
|
-
.description('build static Flowershow website')
|
|
48
|
-
.argument('[project-dir]', 'Path to the folder where Flowershow template is installed (root folder of .flowershow)', '.')
|
|
49
|
-
.action(async (projectPath) => {
|
|
50
|
-
const { default: buildStatic } = await import ('../lib/buildStatic.js');
|
|
51
|
-
buildStatic(projectPath);
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
program
|
|
55
|
-
.command('preview')
|
|
56
|
-
.description('preview your Flowershow site')
|
|
57
|
-
.argument('[project-dir]', 'Path to the folder where Flowershow template is installed (root folder of .flowershow)', '.')
|
|
58
|
-
.action(async (projectPath) => {
|
|
59
|
-
const { default: preview } = await import ('../lib/preview.js');
|
|
60
|
-
preview(projectPath);
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
// TBD
|
|
64
|
-
program
|
|
65
|
-
.command('publish')
|
|
66
|
-
.description('publish files or directories')
|
|
67
|
-
.argument('[path]', 'path to a file or a directory', '.')
|
|
68
|
-
.option('-g, --glob <pattern>', 'glob pattern')
|
|
69
|
-
.action(async () => {
|
|
70
|
-
const { default: publish } = await import ('../lib/publish.js');
|
|
71
|
-
publish();
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
// TBD
|
|
75
|
-
program
|
|
76
|
-
.command('upgrade')
|
|
77
|
-
.description('upgrade your Flowershow template to the latest version')
|
|
78
|
-
.action(async () => {
|
|
79
|
-
const { default: upgrade } = await import ('../lib/upgrade.js');
|
|
80
|
-
upgrade();
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
program.parse();
|
package/lib/Installer.js
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
const require = createRequire(import.meta.url);
|
|
3
|
-
|
|
4
|
-
import fs from 'fs';
|
|
5
|
-
import path from 'path';
|
|
6
|
-
import chalk from 'chalk';
|
|
7
|
-
import degit from 'degit';
|
|
8
|
-
import { execa } from 'execa';
|
|
9
|
-
import inquirer from 'inquirer';
|
|
10
|
-
|
|
11
|
-
import { exit, error, log, success, logWithSpinner, stopSpinner, pauseSpinner, resumeSpinner } from './utils/index.js';
|
|
12
|
-
|
|
13
|
-
import { FLOWERSHOW_FOLDER_NAME } from './const.js';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export default class Creator {
|
|
17
|
-
constructor(context, targetDir, template = 'default') {
|
|
18
|
-
this.context = context;
|
|
19
|
-
this.targetDir = targetDir;
|
|
20
|
-
this.template = template; // tb configurable via command option in the future
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
get templateRepo() {
|
|
24
|
-
const flowershowRepo = require('../package.json').repository.url.replace("git+", "");
|
|
25
|
-
return `${flowershowRepo}/templates/${this.template}`
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async install(options) {
|
|
29
|
-
const { context, targetDir, templateRepo } = this;
|
|
30
|
-
const flowershowDir = path.resolve(targetDir, FLOWERSHOW_FOLDER_NAME)
|
|
31
|
-
|
|
32
|
-
let existsAction;
|
|
33
|
-
if (fs.existsSync(flowershowDir)) {
|
|
34
|
-
let { action } = await inquirer.prompt([
|
|
35
|
-
{
|
|
36
|
-
name: 'action',
|
|
37
|
-
type: 'list',
|
|
38
|
-
message: `Flowershow template is already installed in directory ${chalk.magenta(targetDir)}. What do you want to do?:`,
|
|
39
|
-
choices: [
|
|
40
|
-
{ name: 'Overwrite', value: 'overwrite' },
|
|
41
|
-
// { name: 'Merge', value: 'merge' },
|
|
42
|
-
{ name: 'Cancel', value: null }
|
|
43
|
-
]
|
|
44
|
-
}
|
|
45
|
-
])
|
|
46
|
-
|
|
47
|
-
if (!action) {
|
|
48
|
-
exit(0)
|
|
49
|
-
}
|
|
50
|
-
existsAction = action;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
let { contentPath } = await inquirer.prompt([
|
|
54
|
-
{
|
|
55
|
-
name: 'contentPath',
|
|
56
|
-
type: 'input',
|
|
57
|
-
message: 'Path to the folder with your markdown files',
|
|
58
|
-
validate(input) {
|
|
59
|
-
const contentDir = path.resolve(context, input);
|
|
60
|
-
if (!fs.existsSync(contentDir)) {
|
|
61
|
-
error(`Directory ${contentDir} does not exist.`);
|
|
62
|
-
exit(1);
|
|
63
|
-
}
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
])
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const contentDir = path.resolve(context, contentPath);
|
|
71
|
-
const assetFolderChoices = fs.readdirSync(contentDir, { withFileTypes: true })
|
|
72
|
-
.filter(d => d.isDirectory())
|
|
73
|
-
.map(d => ({ name: d.name, value: d.name }))
|
|
74
|
-
|
|
75
|
-
let assetsFolder = 'none';
|
|
76
|
-
|
|
77
|
-
if (!assetFolderChoices.length) {
|
|
78
|
-
const { foldersAction } = await inquirer.prompt([
|
|
79
|
-
{
|
|
80
|
-
name: 'foldersAction',
|
|
81
|
-
type: 'list',
|
|
82
|
-
message: 'There are no subfolders in your content folder, that could be used as assets folder',
|
|
83
|
-
choices: [
|
|
84
|
-
{ name: "I don't need assets folder", value: 'none' },
|
|
85
|
-
{ name: 'Cancel', value: null }
|
|
86
|
-
]
|
|
87
|
-
}
|
|
88
|
-
])
|
|
89
|
-
|
|
90
|
-
assetsFolder = foldersAction;
|
|
91
|
-
|
|
92
|
-
} else {
|
|
93
|
-
|
|
94
|
-
const { assets } = await inquirer.prompt([
|
|
95
|
-
{
|
|
96
|
-
name: 'assets',
|
|
97
|
-
type: 'list',
|
|
98
|
-
message: 'Select a folder with your assets (attachments)',
|
|
99
|
-
choices: [
|
|
100
|
-
...assetFolderChoices,
|
|
101
|
-
new inquirer.Separator(),
|
|
102
|
-
{ name: "I don't need assets folder", value: 'none' },
|
|
103
|
-
{ name: 'Cancel', value: null }
|
|
104
|
-
]
|
|
105
|
-
}
|
|
106
|
-
])
|
|
107
|
-
|
|
108
|
-
assetsFolder = assets;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (!assetsFolder) {
|
|
112
|
-
exit(0)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// install flowershow template
|
|
116
|
-
logWithSpinner({ symbol: '🌷', msg: `Installing Flowershow template in ${chalk.magenta(flowershowDir)}...` });
|
|
117
|
-
|
|
118
|
-
if (existsAction === 'overwrite') {
|
|
119
|
-
fs.rmSync(flowershowDir, { recursive: true, force: true });
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
try {
|
|
123
|
-
const emitter = degit(templateRepo);
|
|
124
|
-
await emitter.clone(flowershowDir);
|
|
125
|
-
} catch {
|
|
126
|
-
error(`Failed to install Flowershow template in ${flowershowDir}.`)
|
|
127
|
-
exit(1);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// update content and assets symlinks
|
|
131
|
-
fs.unlinkSync(`${flowershowDir}/content`);
|
|
132
|
-
fs.symlinkSync(contentDir, `${flowershowDir}/content`);
|
|
133
|
-
|
|
134
|
-
fs.unlinkSync(`${flowershowDir}/public/assets`);
|
|
135
|
-
if (assetsFolder !== 'none') {
|
|
136
|
-
fs.symlinkSync(path.resolve(contentDir, assetsFolder), `${flowershowDir}/public/${assetsFolder}`);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// // if there is no index.md file, create one
|
|
140
|
-
if (!fs.existsSync(`${contentPath}/index.md`)) {
|
|
141
|
-
const homePageContent = '# Welcome to my Flowershow site!';
|
|
142
|
-
fs.writeFile(`${contentPath}/index.md`, homePageContent, { flag: 'a' }, err => {});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// // if there is no config.js file, create one
|
|
146
|
-
if (!fs.existsSync(`${contentPath}/config.js`)) {
|
|
147
|
-
fs.writeFile(`${contentPath}/config.js`, '{}', { flag: 'a' }, err => {});
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// install flowershow dependencies
|
|
151
|
-
logWithSpinner({ symbol: '🌸', msg: `Installing Flowershow dependencies...` });
|
|
152
|
-
|
|
153
|
-
try {
|
|
154
|
-
await execa('npm', [ 'set-script', 'prepare', '' ], { cwd: flowershowDir });
|
|
155
|
-
const { stdout, stderr } = await execa('npm', [ 'install'], { cwd: flowershowDir });
|
|
156
|
-
log(stdout);
|
|
157
|
-
log(stderr);
|
|
158
|
-
stopSpinner();
|
|
159
|
-
success("Successfuly installed Flowershow!")
|
|
160
|
-
} catch (err) {
|
|
161
|
-
error(
|
|
162
|
-
`Installing dependencies failed: ${err.message}`
|
|
163
|
-
);
|
|
164
|
-
exit(err.exitCode);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
package/lib/build.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { execa } from 'execa';
|
|
4
|
-
|
|
5
|
-
import { exit, error, log } from './utils/index.js';
|
|
6
|
-
import { FLOWERSHOW_FOLDER_NAME } from './const.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export default async function build(dir) {
|
|
10
|
-
const flowershowDir = path.resolve(dir, FLOWERSHOW_FOLDER_NAME);
|
|
11
|
-
|
|
12
|
-
// check if flowershow is installed
|
|
13
|
-
if (!fs.existsSync(flowershowDir)) {
|
|
14
|
-
error(`Directory ${flowershowDir} does not exist.`)
|
|
15
|
-
exit(1);
|
|
16
|
-
}
|
|
17
|
-
const subprocess = execa('npm', [ 'run', 'build' ], { cwd: flowershowDir });
|
|
18
|
-
|
|
19
|
-
subprocess.stdout.pipe(process.stdout);
|
|
20
|
-
}
|
package/lib/buildStatic.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { execa } from 'execa';
|
|
4
|
-
|
|
5
|
-
import { exit, error, log } from './utils/index.js';
|
|
6
|
-
import { FLOWERSHOW_FOLDER_NAME } from './const.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export default async function buildStatic(dir) {
|
|
10
|
-
const flowershowDir = path.resolve(dir, FLOWERSHOW_FOLDER_NAME);
|
|
11
|
-
|
|
12
|
-
const subprocess = execa('npm', [ 'run', 'export' ], { cwd: flowershowDir });
|
|
13
|
-
|
|
14
|
-
subprocess.stdout.pipe(process.stdout);
|
|
15
|
-
}
|
package/lib/const.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const FLOWERSHOW_FOLDER_NAME = '.flowershow';
|
package/lib/preview.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { execa } from 'execa';
|
|
4
|
-
|
|
5
|
-
import { exit, error, log } from './utils/index.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { FLOWERSHOW_FOLDER_NAME } from './const.js';
|
|
9
|
-
|
|
10
|
-
export default async function preview(dir) {
|
|
11
|
-
const flowershowDir = path.resolve(dir, FLOWERSHOW_FOLDER_NAME);
|
|
12
|
-
|
|
13
|
-
// check if flowershow is installed
|
|
14
|
-
if (!fs.existsSync(flowershowDir)) {
|
|
15
|
-
error(`Directory ${flowershowDir} does not exist.`)
|
|
16
|
-
exit(1);
|
|
17
|
-
}
|
|
18
|
-
const subprocess = execa('npm', [ 'run', 'dev' ], { cwd: flowershowDir });
|
|
19
|
-
|
|
20
|
-
subprocess.stdout.pipe(process.stdout);
|
|
21
|
-
}
|
package/lib/publish.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const log = console.log;
|
|
5
|
-
|
|
6
|
-
export default function publish (path, { glob }) {
|
|
7
|
-
log(chalk.redBright.bold('Command under construction...\n'));
|
|
8
|
-
log(chalk.blue(
|
|
9
|
-
'Check ' +
|
|
10
|
-
chalk.green.underline('https://flowershow.app') +
|
|
11
|
-
' to learn more about Flowershow development stage and subscribe to get notified when it\'s ready!'))
|
|
12
|
-
}
|
package/lib/upgrade.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const log = console.log;
|
|
5
|
-
|
|
6
|
-
export default function upgrade () {
|
|
7
|
-
log(chalk.redBright.bold('Command under construction...\n'));
|
|
8
|
-
log(chalk.blue(
|
|
9
|
-
'Check ' +
|
|
10
|
-
chalk.green.underline('https://flowershow.app') +
|
|
11
|
-
' to learn more about Flowershow development stage and subscribe to get notified when it\'s ready!'))
|
|
12
|
-
}
|
package/lib/utils/index.js
DELETED
package/lib/utils/logger.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
|
|
3
|
-
export const log = (msg = '') => {
|
|
4
|
-
console.log(msg);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const info = (msg) => {
|
|
8
|
-
console.log(`${chalk.bgBlueBright.black(' INFO ')} ${msg}`);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const error = (msg) => {
|
|
12
|
-
console.error(`\n${chalk.bgRed(' ERROR ')} ${chalk.red(msg)}`)
|
|
13
|
-
if (msg instanceof Error) {
|
|
14
|
-
console.error(msg.stack)
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const success = (msg) => {
|
|
19
|
-
console.log(`${chalk.blue('🎊')} ${msg}`);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const warn = (msg) => {
|
|
23
|
-
console.log(`${chalk.red('⚠')} ${msg}`);
|
|
24
|
-
}
|