miqro 1.9.0 → 1.9.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/README.md CHANGED
@@ -13,38 +13,38 @@ npx miqro
13
13
  ```
14
14
  Available commands:
15
15
 
16
+
16
17
  ==api development==
17
18
 
18
- new create a new project.
19
- new:typescript create a new typescript project.
20
- new:main creates a new main file.
21
- new:route creates a new route.
22
- config print config as a json.
23
- config:bash print config as a bash script.
24
- config:env print config as a env file.
25
- config:init inits your config folder.
26
- doc api folder auto doc as a json.
27
- doc:md api folder auto doc as a markdown.
19
+ new:api create a new project.
20
+ new:api:main creates a new main file.
21
+ new:api:route creates a new route.
22
+ config print config as a json.
23
+ config:bash print config as a bash script.
24
+ config:env print config as a env file.
25
+ config:init inits your config folder.
26
+ doc api folder auto doc as a json.
27
+ doc:md api folder auto doc as a markdown.
28
28
 
29
29
  ==start helpers==
30
30
 
31
- start start script in cluster mode.
32
- watch watch folder for changes.
33
- serve serve static files.
31
+ start start script in cluster mode.
32
+ watch watch folder for changes.
33
+ serve serve static files.
34
34
 
35
35
  ==testing==
36
36
 
37
- test run test files.
38
- new:test create new test.js file.
37
+ test run test files.
38
+ new:test create new test.js file.
39
39
 
40
40
  ==sequelize helpers==
41
41
 
42
- db:console a query console for sequelize.
43
- db:dump:data dump the data of the database.
44
- db:push:data push a dump to the database.
45
- db:make:migration generate migrations from model changes.
46
- db:make:migration:force:clean:state force 'local' model state.
47
- db:migrate loads config and run migrations.
48
- db:init init sequelize configuration.
49
- db:create:model creates an example model.
42
+ db:console a query console for sequelize.
43
+ db:dump:data dump the data of the database.
44
+ db:push:data push a dump to the database.
45
+ db:make:migration generate migrations from model changes.
46
+ db:migration:forceclean force 'local' model state.
47
+ db:migrate loads config and run migrations.
48
+ db:init init sequelize configuration.
49
+ db:create:model creates an example model.
50
50
  ```
package/dist/cli.js CHANGED
@@ -26,85 +26,91 @@ const db_dump_data_1 = require("./cmds/db-dump-data");
26
26
  const db_migrate_1 = require("./cmds/db-migrate");
27
27
  // noinspection SpellCheckingInspection
28
28
  (0, utils_1.mainCMD)({
29
- ["new"]: { section: "api development", cb: new_1.mainJS, tabs: 5, description: `create a new project.` },
30
- ["new:typescript"]: { cb: new_1.mainTS, tabs: 4, description: `create a new typescript project.` },
31
- ["new:main"]: {
29
+ ["new:api"]: { section: "api development", cb: new_1.mainTS, tabs: 4, description: `create a new project.` },
30
+ //["new:typescript"]: {cb: newTS, tabs: 4, description: `create a new typescript project.`},
31
+ ["new:api:main"]: {
32
32
  //section: "http scafolding",
33
33
  cb: handler_main_new_1.main,
34
- tabs: 4,
34
+ tabs: 3,
35
35
  description: `creates a new main file.`
36
36
  },
37
- ["new:route"]: { cb: handler_apiroute_new_1.main, tabs: 4, description: `creates a new route.` },
37
+ ["new:api:route"]: { cb: handler_apiroute_new_1.main, tabs: 3, description: `creates a new route.` },
38
38
  ["config"]: {
39
39
  //section: "config managment",
40
40
  cb: config_1.main,
41
- tabs: 5,
41
+ tabs: 4,
42
42
  description: `print config as a json.`
43
43
  },
44
44
  ["config:bash"]: {
45
45
  cb: config_bash_1.main,
46
- tabs: 4,
46
+ tabs: 3,
47
47
  description: `print config as a bash script.`
48
48
  },
49
49
  ["config:env"]: {
50
50
  cb: config_env_1.main,
51
- tabs: 4,
51
+ tabs: 3,
52
52
  description: `print config as a env file.`
53
53
  },
54
- ["config:init"]: { cb: config_init_1.main, tabs: 4, description: `inits your config folder.` },
54
+ ["config:init"]: { cb: config_init_1.main, tabs: 3, description: `inits your config folder.` },
55
55
  ["doc"]: {
56
56
  //section: "api documentation",
57
- tabs: 5,
57
+ tabs: 4,
58
58
  cb: doc_json_1.main,
59
59
  description: `api folder auto doc as a json.`
60
60
  },
61
61
  ["doc:md"]: {
62
62
  cb: doc_md_1.main,
63
- tabs: 5,
63
+ tabs: 4,
64
64
  description: `api folder auto doc as a markdown.`
65
65
  },
66
+ /*["new:front"]: {
67
+ section: "front end development",
68
+ cb: newTSFront,
69
+ tabs: 3,
70
+ description: `create a new web-components project.`
71
+ },*/
66
72
  ["start"]: {
67
73
  section: "start helpers",
68
- tabs: 5,
74
+ tabs: 4,
69
75
  cb: start_1.main,
70
76
  description: `start script in cluster mode.`
71
77
  },
72
78
  ["watch"]: {
73
79
  //section: "watch",
74
80
  cb: watch_1.main,
75
- tabs: 5,
81
+ tabs: 4,
76
82
  description: `watch folder for changes.`
77
83
  },
78
84
  ["serve"]: {
79
85
  //section: "serve static files",
80
- tabs: 5,
86
+ tabs: 4,
81
87
  cb: serve_1.main, description: `serve static files.`
82
88
  },
83
- ["test"]: { section: "testing", cb: test_1.main, tabs: 5, description: `run test files.` },
84
- ["new:test"]: { cb: new_test_1.main, tabs: 4, description: `create new test.js file.` },
89
+ ["test"]: { section: "testing", cb: test_1.main, tabs: 4, description: `run test files.` },
90
+ ["new:test"]: { cb: new_test_1.main, tabs: 3, description: `create new test.js file.` },
85
91
  ["db:console"]: {
86
92
  section: "sequelize helpers",
87
93
  cb: db_console_1.main,
88
- tabs: 4,
94
+ tabs: 3,
89
95
  description: `a query console for sequelize.`
90
96
  },
91
97
  ["db:dump:data"]: {
92
98
  cb: db_dump_data_1.main,
93
- tabs: 4,
99
+ tabs: 3,
94
100
  description: `dump the data of the database.`
95
101
  },
96
- ["db:push:data"]: { cb: db_push_data_1.main, tabs: 4, description: `push a dump to the database.` },
102
+ ["db:push:data"]: { cb: db_push_data_1.main, tabs: 3, description: `push a dump to the database.` },
97
103
  ["db:make:migration"]: {
98
104
  cb: db_makemigrations_1.main,
99
- tabs: 3,
105
+ tabs: 2,
100
106
  description: `generate migrations from model changes.`
101
107
  },
102
- ["db:make:migration:force:clean:state"]: {
108
+ ["db:migration:forceclean"]: {
103
109
  cb: db_sync_makemigrations_1.main,
104
- tabs: 1,
110
+ tabs: 2,
105
111
  description: `force 'local' model state.`
106
112
  },
107
- ["db:migrate"]: { cb: db_migrate_1.main, tabs: 4, description: `loads config and run migrations.` },
108
- ["db:init"]: { cb: db_init_1.main, tabs: 5, description: `init sequelize configuration.` },
109
- ["db:create:model"]: { cb: db_createmodel_1.main, tabs: 4, description: `creates an example model.` }
113
+ ["db:migrate"]: { cb: db_migrate_1.main, tabs: 3, description: `loads config and run migrations.` },
114
+ ["db:init"]: { cb: db_init_1.main, tabs: 4, description: `init sequelize configuration.` },
115
+ ["db:create:model"]: { cb: db_createmodel_1.main, tabs: 3, description: `creates an example model.` }
110
116
  }, "npx miqro <command> [args]", console);
@@ -1,2 +1,2 @@
1
- export declare const usage = "usage: [NODE_ENV=development] npx miqro db:make:migration:force:clean:state";
1
+ export declare const usage = "usage: [NODE_ENV=development] npx miqro db:migration:forceclean";
2
2
  export declare const main: () => void;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = exports.usage = void 0;
4
4
  const db_1 = require("../utils/db");
5
5
  const core_1 = require("@miqro/core");
6
- exports.usage = "usage: [NODE_ENV=development] npx miqro db:make:migration:force:clean:state";
6
+ exports.usage = "usage: [NODE_ENV=development] npx miqro db:migration:forceclean";
7
7
  const main = () => {
8
8
  if (process.argv.length !== 3) {
9
9
  throw new Error(`invalid number of args`);
@@ -1,2 +1,2 @@
1
- export declare const usage = "usage: [NODE_ENV=development] npx miqro new:route <identifier ex: SRC_API_V1_HEALTH>";
1
+ export declare const usage = "usage: [NODE_ENV=development] npx miqro new:api:route <identifier ex: SRC_API_V1_HEALTH>";
2
2
  export declare const main: () => void;
@@ -42,7 +42,7 @@ export default {
42
42
  };
43
43
  `
44
44
  };
45
- exports.usage = `usage: [NODE_ENV=development] npx miqro new:route <identifier ex: SRC_API_V1_HEALTH>`;
45
+ exports.usage = `usage: [NODE_ENV=development] npx miqro new:api:route <identifier ex: SRC_API_V1_HEALTH>`;
46
46
  const main = () => {
47
47
  if (process.argv.length !== 4 || process.argv[3].length < 1) {
48
48
  throw new Error(exports.usage);
@@ -1,2 +1,2 @@
1
- export declare const usage = "usage: [NODE_ENV=development] npx miqro new:main <identifier ex: NEW_APP>";
1
+ export declare const usage = "usage: [NODE_ENV=development] npx miqro new:api:main <identifier ex: NEW_APP>";
2
2
  export declare const main: () => void;
@@ -48,7 +48,7 @@ app.listen(PORT, () => {
48
48
  });
49
49
  `
50
50
  };
51
- exports.usage = `usage: [NODE_ENV=development] npx miqro new:main <identifier ex: NEW_APP>`;
51
+ exports.usage = `usage: [NODE_ENV=development] npx miqro new:api:main <identifier ex: NEW_APP>`;
52
52
  const main = () => {
53
53
  if (process.argv.length !== 4 || process.argv[3].length < 1) {
54
54
  throw new Error(exports.usage);
@@ -1,4 +1,2 @@
1
- export declare const usageJS = "usage: npx miqro new <identifier ex: NEW_APP>";
2
- export declare const usageTS = "usage: npx miqro new:typescript <identifier ex: NEW_APP>";
3
- export declare const mainJS: (typescript?: boolean) => void;
1
+ export declare const usageTS = "usage: npx miqro new:api <identifier ex: NEW_APP>";
4
2
  export declare const mainTS: () => void;
package/dist/cmds/new.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mainTS = exports.mainJS = exports.usageTS = exports.usageJS = void 0;
3
+ exports.mainTS = exports.usageTS = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const path_1 = require("path");
6
6
  const utils_1 = require("../utils");
@@ -50,11 +50,10 @@ const packageTemplate = {
50
50
  "license": "ISC"
51
51
  }`
52
52
  };
53
- exports.usageJS = `usage: npx miqro new <identifier ex: NEW_APP>`;
54
- exports.usageTS = `usage: npx miqro new:typescript <identifier ex: NEW_APP>`;
55
- const mainJS = (typescript = false) => {
53
+ exports.usageTS = `usage: npx miqro new:api <identifier ex: NEW_APP>`;
54
+ const mainTS = () => {
56
55
  if (process.argv.length !== 4 || process.argv[3].length < 1) {
57
- throw new Error(typescript ? exports.usageTS : exports.usageJS);
56
+ throw new Error(exports.usageTS);
58
57
  }
59
58
  const identifier = process.argv[3].toLocaleLowerCase();
60
59
  const appFolder = (0, path_1.resolve)(process.cwd(), identifier);
@@ -65,15 +64,14 @@ const mainJS = (typescript = false) => {
65
64
  (0, fs_1.mkdirSync)(appFolder, {
66
65
  recursive: true
67
66
  });
68
- (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "package.json"), packageTemplate[typescript ? "ts" : "js"](identifier));
67
+ (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "package.json"), packageTemplate["ts"](identifier));
69
68
  (0, utils_1.execSync)(`npm install miqro --save-dev`, {
70
69
  cwd: appFolder
71
70
  });
72
71
  (0, utils_1.execSync)(`npm install @miqro/core --save`, {
73
72
  cwd: appFolder
74
73
  });
75
- if (typescript) {
76
- (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "tsconfig.json"), `{
74
+ (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "tsconfig.json"), `{
77
75
  "compileOnSave": true,
78
76
  "compilerOptions": {
79
77
  "lib": ["es2021"],
@@ -97,24 +95,20 @@ const mainJS = (typescript = false) => {
97
95
  "src"
98
96
  ]
99
97
  }`);
100
- (0, utils_1.execSync)(`npm install typescript --save-dev`, {
101
- cwd: appFolder
102
- });
103
- (0, utils_1.execSync)(`npm install @types/node --save-dev`, {
104
- cwd: appFolder
105
- });
106
- (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, ".gitignore"), gitignoreTemplate.ts());
107
- }
108
- else {
109
- (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, ".gitignore"), gitignoreTemplate.js());
110
- }
98
+ (0, utils_1.execSync)(`npm install typescript --save-dev`, {
99
+ cwd: appFolder
100
+ });
101
+ (0, utils_1.execSync)(`npm install @types/node --save-dev`, {
102
+ cwd: appFolder
103
+ });
104
+ (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, ".gitignore"), gitignoreTemplate.ts());
111
105
  (0, utils_1.execSync)(`npm install @miqro/test --save-dev`, {
112
106
  cwd: appFolder
113
107
  });
114
- (0, utils_1.execSync)(`npx miqro new:main src_main`, {
108
+ (0, utils_1.execSync)(`npx miqro new:api:main src_main`, {
115
109
  cwd: appFolder
116
110
  });
117
- (0, utils_1.execSync)(`npx miqro new:route src_api_health`, {
111
+ (0, utils_1.execSync)(`npx miqro new:api:route src_api_health`, {
118
112
  cwd: appFolder
119
113
  });
120
114
  (0, fs_1.mkdirSync)((0, path_1.resolve)(appFolder, "test"), {
@@ -127,6 +121,4 @@ const mainJS = (typescript = false) => {
127
121
  console.log(`cd ${identifier}`);
128
122
  console.log(`npm run start`);
129
123
  };
130
- exports.mainJS = mainJS;
131
- const mainTS = () => (0, exports.mainJS)(true);
132
124
  exports.mainTS = mainTS;
@@ -0,0 +1,2 @@
1
+ export declare const usageTS = "usage: npx miqro new:front <identifier ex: NEW_APP>";
2
+ export declare const mainTS: () => void;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mainTS = exports.usageTS = 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
+ `<app-component></app-component>` +
12
+ `</body>` +
13
+ `</html>`
14
+ };
15
+ const indexComponent = {
16
+ ts: () => `import WebComponents, {JSX, define, RenderFunctionThis} from "@miqro/web-components"\n` +
17
+ `\n` +
18
+ `define("app-component", function(this: RenderFunctionThis): JSX.Element {\n` +
19
+ ` return (<p>Hello World!</p>);\n` +
20
+ `});\n`
21
+ };
22
+ const webpackconfig = {
23
+ ts: () => `const mode = process.env.NODE_ENV ? process.env.NODE_ENV : "development";
24
+ console.log("webpack mode [%s]", mode);
25
+ module.exports = {` +
26
+ ` mode: "production",` +
27
+ ` entry: "./dist/index.js",` +
28
+ ` output: {` +
29
+ ` path: require("path").resolve(__dirname, 'build'),` +
30
+ ` filename: "app.bundle.min.js"` +
31
+ ` }` +
32
+ `};`,
33
+ };
34
+ const gitignoreTemplate = {
35
+ ts: () => `node_modules/
36
+ dist/
37
+ `
38
+ };
39
+ const packageTemplate = {
40
+ ts: (name) => `{
41
+ "name": "${name}",
42
+ "version": "1.0.0",
43
+ "description": "",
44
+ "private": true,
45
+ "main": "dist/main.js",
46
+ "scripts": {
47
+ "prebuild": "rm -Rf build/; rm -Rf dist/; mkdir build && cp -R public/ build/",
48
+ "build": "tsc && NODE_ENV=production webpack",
49
+ "build:dev": "tsc && webpack",
50
+ "prestart": "npm run build:dev",
51
+ "start": "miqro serve build/ / --port 3000 & miqro watch src/ \\"npm run build:dev\\""
52
+ },
53
+ "devDependencies": {
54
+ },
55
+ "dependencies": {
56
+ },
57
+ "author": "",
58
+ "license": "ISC"
59
+ }`
60
+ };
61
+ exports.usageTS = `usage: npx miqro new:front <identifier ex: NEW_APP>`;
62
+ const mainTS = () => {
63
+ if (process.argv.length !== 4 || process.argv[3].length < 1) {
64
+ throw new Error(exports.usageTS);
65
+ }
66
+ const identifier = process.argv[3].toLocaleLowerCase();
67
+ const appFolder = (0, path_1.resolve)(process.cwd(), identifier);
68
+ if ((0, fs_1.existsSync)(appFolder)) {
69
+ throw new Error(`${appFolder} already exists!`);
70
+ }
71
+ console.log(`creating ${appFolder}`);
72
+ (0, fs_1.mkdirSync)(appFolder, {
73
+ recursive: true
74
+ });
75
+ (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "package.json"), packageTemplate["ts"](identifier));
76
+ (0, utils_1.execSync)(`npm install miqro --save-dev`, {
77
+ cwd: appFolder
78
+ });
79
+ /*execSync(
80
+ `npm install @miqro/web-components --save`,
81
+ {
82
+ cwd: appFolder
83
+ }
84
+ );*/
85
+ (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "tsconfig.json"), `{
86
+ "compileOnSave": true,
87
+ "compilerOptions": {
88
+ "lib": ["es2021", "dom"],
89
+ "module": "commonjs",
90
+ "moduleResolution": "node",
91
+ "target": "es2021",
92
+ "strict": false,
93
+ "outDir": "./dist/",
94
+ "jsx": "react",
95
+ "jsxFactory": "WebComponents.jsxFactory",
96
+ "jsxFragmentFactory": "WebComponents.jsxFragmentFactory"
97
+ },
98
+ "exclude": [
99
+ "node_modules",
100
+ "test"
101
+ ],
102
+ "include": [
103
+ "src"
104
+ ]
105
+ }`);
106
+ (0, utils_1.execSync)(`npm install typescript --save-dev`, {
107
+ cwd: appFolder
108
+ });
109
+ (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, ".gitignore"), gitignoreTemplate.ts());
110
+ (0, utils_1.execSync)(`npm install webpack-cli --save-dev`, {
111
+ cwd: appFolder
112
+ });
113
+ (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "webpack.config.js"), webpackconfig.ts());
114
+ (0, fs_1.mkdirSync)((0, path_1.resolve)(appFolder, "src"));
115
+ (0, fs_1.mkdirSync)((0, path_1.resolve)(appFolder, "public"));
116
+ (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "public", "index.html"), indexHTML.js());
117
+ (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, "src", "index" + (".tsx")), indexComponent.ts());
118
+ console.log(`new project created on ${appFolder}`);
119
+ console.log(`cd ${identifier}`);
120
+ console.log(`npm run start`);
121
+ };
122
+ exports.mainTS = mainTS;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miqro",
3
- "version": "1.9.0",
3
+ "version": "1.9.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,10 +17,10 @@
17
17
  "author": "claukers",
18
18
  "license": "ISC",
19
19
  "dependencies": {
20
- "@miqro/core": "^1.7.0",
21
- "@miqro/parser": "^0.1.5",
22
- "@miqro/runner": "^1.2.8",
23
- "@miqro/test": "^0.2.4",
20
+ "@miqro/core": "^1.7.3",
21
+ "@miqro/parser": "^0.1.6",
22
+ "@miqro/runner": "^1.2.9",
23
+ "@miqro/test": "^0.2.8",
24
24
  "deep-diff": "1.0.2"
25
25
  },
26
26
  "devDependencies": {