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.
@@ -0,0 +1,3 @@
1
+ export const announce = ({ inResolvedFolderName }) => {
2
+ console.log(`[keshavsoft] Project created: ${inResolvedFolderName}`);
3
+ };
@@ -0,0 +1,7 @@
1
+ import fs from "fs";
2
+
3
+ export const createProject = ({ source, destination }) => {
4
+ fs.mkdirSync(destination, { recursive: true });
5
+
6
+ fs.cpSync(source, destination, { recursive: true });
7
+ };
@@ -0,0 +1,5 @@
1
+ import path from "path";
2
+
3
+ export const locateDestination = ({ inResolvedFolderName }) => {
4
+ return path.join(process.cwd(), inResolvedFolderName);
5
+ };
@@ -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,4 @@
1
+ const hookAllListeners = () => {
2
+ };
3
+
4
+ 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
+ };
@@ -1,8 +1,10 @@
1
1
  import init from "../commands/init.js";
2
+ import addListeners from "../commands/addListeners.js";
2
3
 
3
4
  // resolveCommand.js
4
5
  const map = {
5
- init
6
+ init,
7
+ addListeners
6
8
  };
7
9
 
8
10
  export default function resolveCommand(cmd) {
package/bin/v2/start.js CHANGED
@@ -11,6 +11,7 @@ const run = async () => {
11
11
  const input = parseInput();
12
12
 
13
13
  if (input.action === "--help" || input.action === "-h" || input.action === "help") return showUsage(version);
14
+ console.log("input : ", input);
14
15
 
15
16
  const command = resolveCommand(input.cmd);
16
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-crud-ui",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "working on ui for our json crud using modules",
5
5
  "keywords": [
6
6
  "cli",