json-crud-ui 1.2.1 → 1.2.2
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/bin/v2/commands/addListeners/steps/announce.js +3 -0
- package/bin/v2/commands/addListeners/steps/createProject.js +7 -0
- package/bin/v2/commands/addListeners/steps/locateDestination.js +5 -0
- package/bin/v2/commands/addListeners/steps/locateSource.js +32 -0
- package/bin/v2/commands/addListeners/steps/resolveFolderName.js +17 -0
- package/bin/v2/commands/addListeners/template/v1/AddListeners/start.js +14 -0
- package/bin/v2/commands/addListeners/template/v2/start.js +4 -0
- package/bin/v2/commands/addListeners.js +20 -0
- package/bin/v2/core/resolveCommand.js +3 -1
- package/bin/v2/start.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
|
|
9
|
+
const templatePath = path.join(
|
|
10
|
+
__dirname,
|
|
11
|
+
"..",
|
|
12
|
+
"template"
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const versions = fs
|
|
16
|
+
.readdirSync(templatePath)
|
|
17
|
+
.filter(item => item.startsWith("v"));
|
|
18
|
+
|
|
19
|
+
const highestVersion =
|
|
20
|
+
versions.sort().at(-1);
|
|
21
|
+
|
|
22
|
+
const sourceVersion =
|
|
23
|
+
highestVersion;
|
|
24
|
+
|
|
25
|
+
export const locateSource = () => {
|
|
26
|
+
return path.join(
|
|
27
|
+
__dirname,
|
|
28
|
+
"..",
|
|
29
|
+
"template",
|
|
30
|
+
sourceVersion
|
|
31
|
+
);
|
|
32
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
|
|
3
|
+
export default function resolveFolderName({ name, inType = "basic" }) {
|
|
4
|
+
const defaultFolerName = "AddListeners";
|
|
5
|
+
|
|
6
|
+
// case 1: force new → timestamp
|
|
7
|
+
if (name === null) {
|
|
8
|
+
name = defaultFolerName;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// case 2: user provided → strict
|
|
12
|
+
if (fs.existsSync(name)) {
|
|
13
|
+
throw new Error(`Folder already exists: ${name}`);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return name;
|
|
17
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { funcToRun as funcToRunForLedgersHtmlId } from "./LedgersHtmlId/start.js";
|
|
2
|
+
import { funcToRun as funcToRunForStockItemsHtmlId } from "./StockItemsHtmlId/start.js";
|
|
3
|
+
|
|
4
|
+
import { funcToRun as funcToRunForImportHtmlId } from "./ImportHtmlId/start.js";
|
|
5
|
+
|
|
6
|
+
const hookAllListeners = () => {
|
|
7
|
+
funcToRunForLedgersHtmlId();
|
|
8
|
+
funcToRunForStockItemsHtmlId();
|
|
9
|
+
|
|
10
|
+
funcToRunForImportHtmlId();
|
|
11
|
+
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { hookAllListeners };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { locateSource } from "./addListeners/steps/locateSource.js";
|
|
2
|
+
import { locateDestination } from "./addListeners/steps/locateDestination.js";
|
|
3
|
+
|
|
4
|
+
import { createProject } from "./addListeners/steps/createProject.js";
|
|
5
|
+
import { announce } from "./addListeners/steps/announce.js";
|
|
6
|
+
|
|
7
|
+
import resolveFolderName from "./addListeners/steps/resolveFolderName.js";
|
|
8
|
+
|
|
9
|
+
export default ({ folderName = "", toPath = process.cwd(), inAnnounce = true }) => {
|
|
10
|
+
const resolvedFolderName = resolveFolderName({
|
|
11
|
+
name: folderName
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const source = locateSource();
|
|
15
|
+
const destination = locateDestination({ inResolvedFolderName: resolvedFolderName });
|
|
16
|
+
|
|
17
|
+
createProject({ source, destination });
|
|
18
|
+
|
|
19
|
+
if (inAnnounce) announce({ inResolvedFolderName: resolvedFolderName });
|
|
20
|
+
};
|
package/bin/v2/start.js
CHANGED