miqro 1.8.1 → 1.8.3

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/dist/cli.js CHANGED
@@ -6,6 +6,7 @@ const start_1 = require("./cmds/start");
6
6
  const test_1 = require("./cmds/test");
7
7
  const watch_1 = require("./cmds/watch");
8
8
  const new_1 = require("./cmds/new");
9
+ const wc_new_1 = require("./cmds/wc-new");
9
10
  const doc_json_1 = require("./cmds/doc-json");
10
11
  const doc_md_1 = require("./cmds/doc-md");
11
12
  const config_init_1 = require("./cmds/config-init");
@@ -28,17 +29,17 @@ const db_migrate_1 = require("./cmds/db-migrate");
28
29
  const wc_cache_templates_1 = require("./cmds/wc-cache-templates");
29
30
  // noinspection SpellCheckingInspection
30
31
  (0, utils_1.mainCMD)({
31
- ["new"]: { section: "quick start", cb: new_1.mainJS, tabs: 5, description: `create a new project. ${new_1.usageJS}` },
32
+ ["new"]: { section: "api development", cb: new_1.mainJS, tabs: 5, description: `create a new project. ${new_1.usageJS}` },
32
33
  ["new:typescript"]: { cb: new_1.mainTS, tabs: 4, description: `create a new typescript project. ${new_1.usageTS}` },
33
34
  ["new:main"]: {
34
- section: "http scafolding",
35
+ //section: "http scafolding",
35
36
  cb: handler_main_new_1.main,
36
37
  tabs: 4,
37
38
  description: `creates a new main file. ${handler_main_new_1.usage}`
38
39
  },
39
40
  ["new:route"]: { cb: handler_apiroute_new_1.main, tabs: 4, description: `creates a new route. ${handler_apiroute_new_1.usage}` },
40
41
  ["config"]: {
41
- section: "config managment",
42
+ //section: "config managment",
42
43
  cb: config_1.main,
43
44
  tabs: 5,
44
45
  description: `outputs to stdout the config as a json. ${config_1.usage}`
@@ -54,6 +55,28 @@ const wc_cache_templates_1 = require("./cmds/wc-cache-templates");
54
55
  description: `outputs to stdout the config as a env file. ${config_env_1.usage}`
55
56
  },
56
57
  ["config:init"]: { cb: config_init_1.main, tabs: 4, description: `inits your config folder. ${config_init_1.usage}` },
58
+ ["doc"]: {
59
+ //section: "api documentation",
60
+ tabs: 5,
61
+ cb: doc_json_1.main,
62
+ description: `outputs to stdout an api folder auto doc as a json. ${doc_json_1.usage}`
63
+ },
64
+ ["doc:md"]: {
65
+ cb: doc_md_1.main,
66
+ tabs: 5,
67
+ description: `outputs to a file an api folder auto doc as a markdown. ${doc_md_1.usage}`
68
+ },
69
+ ["new:front"]: { section: "front development", cb: wc_new_1.mainJS, tabs: 4, description: `create a new project. ${wc_new_1.usageJS}` },
70
+ ["new:front:typescript"]: { cb: wc_new_1.mainTS, tabs: 3, description: `create a new typescript project. ${wc_new_1.usageTS}` },
71
+ ["generate:template:cache"]: {
72
+ //section: "web components",
73
+ tabs: 3,
74
+ cb: wc_cache_templates_1.main, description: `generate a cache.json for webcomponents. ${wc_cache_templates_1.usage}`
75
+ },
76
+ /*["sfc"]: {
77
+ tabs: 6,
78
+ cb: wcCompileSFC, description: `transpiles a single file webcomponent to commonjs file for packing. ${wcCompileSFCUsage}`
79
+ },*/
57
80
  ["start"]: {
58
81
  section: "start helpers",
59
82
  tabs: 5,
@@ -71,26 +94,6 @@ const wc_cache_templates_1 = require("./cmds/wc-cache-templates");
71
94
  tabs: 5,
72
95
  cb: serve_1.main, description: `serve static files. ${serve_1.usage}`
73
96
  },
74
- ["generate:template:cache"]: {
75
- section: "web components",
76
- tabs: 6,
77
- cb: wc_cache_templates_1.main, description: `generate a cache.json for webcomponents. ${wc_cache_templates_1.usage}`
78
- },
79
- /*["sfc"]: {
80
- tabs: 6,
81
- cb: wcCompileSFC, description: `transpiles a single file webcomponent to commonjs file for packing. ${wcCompileSFCUsage}`
82
- },*/
83
- ["doc"]: {
84
- section: "api documentation",
85
- tabs: 5,
86
- cb: doc_json_1.main,
87
- description: `outputs to stdout an api folder auto doc as a json. ${doc_json_1.usage}`
88
- },
89
- ["doc:md"]: {
90
- cb: doc_md_1.main,
91
- tabs: 5,
92
- description: `outputs to a file an api folder auto doc as a markdown. ${doc_md_1.usage}`
93
- },
94
97
  ["test"]: { section: "testing", cb: test_1.main, tabs: 5, description: `run test files. ${test_1.usage}` },
95
98
  ["new:test"]: { cb: new_test_1.main, tabs: 4, description: `create new test.js file. ${new_test_1.usage}` },
96
99
  ["db:console"]: {
@@ -0,0 +1,4 @@
1
+ export declare const usageJS = "usage: npx miqro new:front <identifier ex: NEW_APP>";
2
+ export declare const usageTS = "usage: npx miqro new:front:typescript <identifier ex: NEW_APP>";
3
+ export declare const mainJS: (typescript?: boolean) => void;
4
+ export declare const mainTS: () => void;
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mainTS = exports.mainJS = exports.usageTS = exports.usageJS = void 0;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ const utils_1 = require("../utils");
7
+ const indexHTML = {
8
+ js: () => `<html>` +
9
+ `<script type="text/javascript" src="app.bundle.min.js"></script>` +
10
+ `<body>` +
11
+ `<my-app></my-app>` +
12
+ `</body>` +
13
+ `</html>`
14
+ };
15
+ const indexComponent = {
16
+ js: () => `const {define} = require("@miqro/web-components")\n` +
17
+ `\n` +
18
+ `define("my-app", function() {\n` +
19
+ ` return "<p>Hello World!</p>";\n` +
20
+ `});`,
21
+ ts: () => `import {define, RenderFunctionThis} from "@miqro/web-components"\n` +
22
+ `\n` +
23
+ `define("my-app", function(this: RenderFunctionThis) {\n` +
24
+ ` return "<p>Hello World!</p>";\n` +
25
+ `});`
26
+ };
27
+ const webpackconfig = {
28
+ js: () => `module.exports = {\n` +
29
+ ` mode: "production",\n` +
30
+ ` entry: "./src/index.js",\n` +
31
+ ` output: {\n` +
32
+ ` path: require("path").resolve(__dirname, 'build'),\n` +
33
+ ` filename: "app.bundle.min.js"\n` +
34
+ ` }\n` +
35
+ `};`,
36
+ ts: () => `module.exports = {\n` +
37
+ ` mode: "production",\n` +
38
+ ` entry: "./dist/index.js",\n` +
39
+ ` output: {\n` +
40
+ ` path: require("path").resolve(__dirname, 'build'),\n` +
41
+ ` filename: "app.bundle.min.js"\n` +
42
+ ` }\n` +
43
+ `};`,
44
+ };
45
+ const gitignoreTemplate = {
46
+ ts: () => `node_modules/
47
+ dist/
48
+ `,
49
+ js: () => `node_modules/`
50
+ };
51
+ const packageTemplate = {
52
+ ts: (name) => `{
53
+ "name": "${name}",
54
+ "version": "1.0.0",
55
+ "description": "",
56
+ "private": true,
57
+ "main": "dist/main.js",
58
+ "scripts": {
59
+ "prebuild": "rm -Rf build/; rm -Rf dist/; mkdir build && cp -R public/ build/",
60
+ "build": "tsc && webpack",
61
+ "prestart": "npm run build",
62
+ "start": "npx miqro serve build/ /"
63
+ },
64
+ "devDependencies": {
65
+ },
66
+ "dependencies": {
67
+ },
68
+ "author": "",
69
+ "license": "ISC"
70
+ }`,
71
+ js: (name) => `{
72
+ "name": "${name}",
73
+ "version": "1.0.0",
74
+ "description": "",
75
+ "private": true,
76
+ "main": "src/main.js",
77
+ "scripts": {
78
+ "prebuild": "rm -Rf build/; rm -Rf dist/; mkdir build && cp -R public/ build/",
79
+ "build": "webpack",
80
+ "prestart": "npm run build",
81
+ "start": "npx miqro serve build/ /"
82
+ },
83
+ "devDependencies": {
84
+ },
85
+ "dependencies": {
86
+ },
87
+ "author": "",
88
+ "license": "ISC"
89
+ }`
90
+ };
91
+ exports.usageJS = `usage: npx miqro new:front <identifier ex: NEW_APP>`;
92
+ exports.usageTS = `usage: npx miqro new:front:typescript <identifier ex: NEW_APP>`;
93
+ const mainJS = (typescript = false) => {
94
+ if (process.argv.length !== 4 || process.argv[3].length < 1) {
95
+ throw new Error(typescript ? exports.usageTS : exports.usageJS);
96
+ }
97
+ const identifier = process.argv[3].toLocaleLowerCase();
98
+ const appFolder = (0, path_1.resolve)(process.cwd(), identifier);
99
+ if ((0, fs_1.existsSync)(appFolder)) {
100
+ throw new Error(`${appFolder} already exists!`);
101
+ }
102
+ console.log(`creating ${appFolder}`);
103
+ (0, fs_1.mkdirSync)(appFolder, {
104
+ recursive: true
105
+ });
106
+ (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "package.json"), packageTemplate[typescript ? "ts" : "js"](identifier));
107
+ (0, utils_1.execSync)(`npm install miqro --save-dev`, {
108
+ cwd: appFolder
109
+ });
110
+ (0, utils_1.execSync)(`npm install @miqro/web-components --save`, {
111
+ cwd: appFolder
112
+ });
113
+ if (typescript) {
114
+ (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "tsconfig.json"), `{
115
+ "compileOnSave": true,
116
+ "compilerOptions": {
117
+ "lib": ["es2021", "dom"],
118
+ "module": "commonjs",
119
+ "moduleResolution": "node",
120
+ "target": "es2021",
121
+ "strict": false,
122
+ "outDir": "./dist/",
123
+ "removeComments": true,
124
+ "noImplicitAny": false,
125
+ "preserveConstEnums": true,
126
+ "sourceMap": true,
127
+ "esModuleInterop": true,
128
+ "declaration": true
129
+ },
130
+ "exclude": [
131
+ "node_modules",
132
+ "test"
133
+ ],
134
+ "include": [
135
+ "src"
136
+ ]
137
+ }`);
138
+ (0, utils_1.execSync)(`npm install typescript --save-dev`, {
139
+ cwd: appFolder
140
+ });
141
+ (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, ".gitignore"), gitignoreTemplate.ts());
142
+ }
143
+ else {
144
+ (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, ".gitignore"), gitignoreTemplate.js());
145
+ }
146
+ (0, utils_1.execSync)(`npm install webpack-cli --save-dev`, {
147
+ cwd: appFolder
148
+ });
149
+ (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "webpack.config.js"), typescript ? webpackconfig.ts() : webpackconfig.js());
150
+ (0, fs_1.mkdirSync)((0, path_1.resolve)(appFolder, "src"));
151
+ (0, fs_1.mkdirSync)((0, path_1.resolve)(appFolder, "public"));
152
+ (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "public", "index.html"), indexHTML.js());
153
+ (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "src", "index" + (typescript ? ".ts" : ".js")), typescript ? indexComponent.ts() : indexComponent.js());
154
+ console.log(`new project created on ${appFolder}`);
155
+ console.log(`cd ${identifier}`);
156
+ console.log(`npm run start`);
157
+ };
158
+ exports.mainJS = mainJS;
159
+ const mainTS = () => (0, exports.mainJS)(true);
160
+ exports.mainTS = mainTS;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miqro",
3
- "version": "1.8.1",
3
+ "version": "1.8.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",