@jay-framework/jay-cli 0.6.7 → 0.6.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.
Files changed (2) hide show
  1. package/dist/index.js +28 -27
  2. package/package.json +6 -4
package/dist/index.js CHANGED
@@ -1,18 +1,19 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- const rollup = require("rollup");
4
- const commander = require("commander");
5
- const compiler = require("@jay-framework/compiler");
6
- const rollupPlugin = require("@jay-framework/rollup-plugin");
7
- const chalk = require("chalk");
8
- const fastGlob = require("fast-glob");
9
- const compilerShared = require("@jay-framework/compiler-shared");
10
- const fs = require("fs");
11
- const path = require("path");
12
- const compilerJayHtml = require("@jay-framework/compiler-jay-html");
13
- const path$1 = require("node:path");
2
+ import { rollup } from "rollup";
3
+ import { Command } from "commander";
4
+ import { generateElementFile } from "@jay-framework/compiler";
5
+ import { jayDefinitions } from "@jay-framework/rollup-plugin";
6
+ import chalk from "chalk";
7
+ import * as fastGlob from "fast-glob";
8
+ import { JAY_EXTENSION, checkValidationErrors, GenerateTarget, RuntimeMode, JAY_CONTRACT_EXTENSION } from "@jay-framework/compiler-shared";
9
+ import fs, { promises } from "fs";
10
+ import path from "path";
11
+ import { parseJayFile, JAY_IMPORT_RESOLVER } from "@jay-framework/compiler-jay-html";
12
+ import { glob as glob$1 } from "glob";
13
+ import path$1 from "node:path";
14
+ const { glob } = fastGlob;
14
15
  async function findAllJayFiles(dir) {
15
- return await fastGlob.glob(`${dir}/**/*${compilerShared.JAY_EXTENSION}`);
16
+ return await glob(`${dir}/**/*${JAY_EXTENSION}`);
16
17
  }
17
18
  function checkFileExists(filepath) {
18
19
  return new Promise((resolve, reject) => {
@@ -27,20 +28,20 @@ async function generateFiles(dir, codeGenerationFunction, afterGenerationFunctio
27
28
  console.log(dir, jayFiles);
28
29
  let generationFailed = false;
29
30
  for (const jayFile of jayFiles) {
30
- const content = await fs.promises.readFile(jayFile, "utf-8");
31
- const parsedFile = compilerShared.checkValidationErrors(
32
- await compilerJayHtml.parseJayFile(
31
+ const content = await promises.readFile(jayFile, "utf-8");
32
+ const parsedFile = checkValidationErrors(
33
+ await parseJayFile(
33
34
  content,
34
35
  path.basename(jayFile.replace(".jay-html", "")),
35
36
  path.dirname(jayFile),
36
37
  {},
37
- compilerJayHtml.JAY_IMPORT_RESOLVER
38
+ JAY_IMPORT_RESOLVER
38
39
  )
39
40
  );
40
- const generateTarget = compilationTarget === "react" ? compilerShared.GenerateTarget.react : compilerShared.GenerateTarget.jay;
41
+ const generateTarget = compilationTarget === "react" ? GenerateTarget.react : GenerateTarget.jay;
41
42
  const generatedFile = codeGenerationFunction(
42
43
  parsedFile,
43
- compilerShared.RuntimeMode.MainTrusted,
44
+ RuntimeMode.MainTrusted,
44
45
  generateTarget
45
46
  );
46
47
  const generateFileName = jayFile + outputExtension;
@@ -71,9 +72,9 @@ async function generateFiles(dir, codeGenerationFunction, afterGenerationFunctio
71
72
  destinationGeneratedFileName = generateFileName;
72
73
  let destinationDirName = path.dirname(destinationGeneratedFileName);
73
74
  if (!await checkFileExists(destinationDirName)) {
74
- await fs.promises.mkdir(destinationDirName, { recursive: true });
75
+ await promises.mkdir(destinationDirName, { recursive: true });
75
76
  }
76
- await fs.promises.writeFile(destinationGeneratedFileName, generatedFile.val);
77
+ await promises.writeFile(destinationGeneratedFileName, generatedFile.val);
77
78
  }
78
79
  afterGenerationFunction(
79
80
  content,
@@ -87,21 +88,21 @@ async function generateFiles(dir, codeGenerationFunction, afterGenerationFunctio
87
88
  }
88
89
  function getJayHtmlOrContractFileInputs(source) {
89
90
  return Object.fromEntries(
90
- fastGlob.globSync(`${source}/**/*{${compilerShared.JAY_EXTENSION},${compilerShared.JAY_CONTRACT_EXTENSION}}`).map((file) => {
91
- const moduleName = file.includes(compilerShared.JAY_EXTENSION) ? file.slice(0, file.length - compilerShared.JAY_EXTENSION.length) : file.slice(0, file.length - compilerShared.JAY_CONTRACT_EXTENSION.length);
91
+ glob$1.sync(`${source}/**/*{${JAY_EXTENSION},${JAY_CONTRACT_EXTENSION}}`).map((file) => {
92
+ const moduleName = file.includes(JAY_EXTENSION) ? file.slice(0, file.length - JAY_EXTENSION.length) : file.slice(0, file.length - JAY_CONTRACT_EXTENSION.length);
92
93
  return [path$1.relative(source, moduleName), file];
93
94
  })
94
95
  );
95
96
  }
96
- const program = new commander.Command();
97
+ const program = new Command();
97
98
  const noop = () => void 0;
98
99
  program.command("definitions").argument("<source>", "source folder to scan for .jay-html files").description("generate definition files (.d.ts) for jay files").action(async (source) => {
99
- await rollup.rollup({
100
+ await rollup({
100
101
  input: getJayHtmlOrContractFileInputs(source),
101
- plugins: [rollupPlugin.jayDefinitions()]
102
+ plugins: [jayDefinitions()]
102
103
  });
103
104
  });
104
105
  program.command("runtime").argument("<source>", "source folder to scan for .jay-html files").argument("[destination]", "destination folder for generated files").argument("[compilationTarget]", "jay | react. target runtime to compile for. Defaults to jay").description("generate code files (.ts) for jay files").action(async (source, dest, compilationTarget) => {
105
- await generateFiles(source, compiler.generateElementFile, noop, ".ts", dest, compilationTarget);
106
+ await generateFiles(source, generateElementFile, noop, ".ts", dest, compilationTarget);
106
107
  });
107
108
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@jay-framework/jay-cli",
3
- "version": "0.6.7",
3
+ "version": "0.6.9",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/index.js",
6
6
  "bin": "dist/index.js",
7
+ "type": "module",
7
8
  "files": [
8
9
  "dist",
9
10
  "readme.md"
@@ -20,14 +21,15 @@
20
21
  "test:watch": ":"
21
22
  },
22
23
  "dependencies": {
23
- "@jay-framework/compiler": "^0.6.7",
24
- "@jay-framework/rollup-plugin": "^0.6.7",
24
+ "@jay-framework/compiler": "^0.6.9",
25
+ "@jay-framework/rollup-plugin": "^0.6.9",
25
26
  "chalk": "^4.1.2",
26
27
  "commander": "^14.0.0",
28
+ "glob": "^10.4.5",
27
29
  "rollup": "^4.9.5"
28
30
  },
29
31
  "devDependencies": {
30
- "@jay-framework/dev-environment": "^0.6.7",
32
+ "@jay-framework/dev-environment": "^0.6.9",
31
33
  "@types/node": "^20.11.5",
32
34
  "@types/shelljs": "^0.8.15",
33
35
  "rimraf": "^5.0.5",