Browse Source

Merge branch 'master' of ssh://code.fineres.com:7999/~dailer/fineui

es6
zsmj 2 years ago
parent
commit
d0a67bd6a1
  1. 6
      .eslintrc
  2. 2
      .npmignore
  3. 44
      bin/cli/cli.js
  4. 62
      bin/cli/worker/cli.worker.js
  5. 0
      bin/cli/worker/template/action_type.ts
  6. 5
      bin/cli/worker/template/main_thread_template.ts
  7. 5
      bin/cli/worker/template/worker_thread_template.ts
  8. 5
      package.json
  9. 1
      src/widget/dynamicdate/dynamicdate.combo.js

6
.eslintrc

@ -17,7 +17,6 @@
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
@ -34,7 +33,10 @@
"comma-dangle": ["error", "never"] // 多行对象字面量中要求拖尾逗号
}
}, {
"files": ["webpack/*.js", "types/*.ts", "typescript/*.ts","typescript/**/*.ts", "./*.js", "lib/**/*.js", "lib/*.js"],
"files": ["webpack/*.js", "./*.js", "lib/**/*.js", "lib/*.js", "./bin/*.js", "./bin/**/*.js"],
"extends": "plugin:@fui/esnext"
}, {
"files": ["types/*.ts", "typescript/*.ts","typescript/**/*.ts"],
"extends": "plugin:@fui/typescript"
}]
}

2
.npmignore

@ -38,3 +38,5 @@
!.eslintrc
!dist/2.0/jsy.min.css
!dist/2.0/bi.min.css
!bin/*
!bin/**/*

44
bin/cli/cli.js

@ -0,0 +1,44 @@
#!/usr/bin/env node
const workerCmd = require('./worker/cli.worker');
function getArgs (startIndex = 1) {
const args = {};
process.argv
.slice(startIndex, process.argv.length)
.forEach(arg => {
// long arg
if (arg.slice(0, 2) === '--') {
const longArg = arg.split('=');
const longArgFlag = longArg[0].slice(2, longArg[0].length);
const longArgValue = longArg.length > 1 ? longArg[1] : true;
args[longArgFlag] = longArgValue;
// flags
} else if (arg[0] === '-') {
const flags = arg.slice(1, arg.length);
args[flags] = true;
}
});
return args;
}
const cmds = new Map([
['worker', workerCmd],
]);
const baseCmd = 'fui-cli';
const startIndex = process.argv.findIndex(argv => argv.indexOf(baseCmd) !== -1);
if (startIndex === -1) {
throw new Error(`Command ${baseCmd} not found in args`);
}
const cmd = process.argv[startIndex + 1];
if (cmds.has(cmd)) {
cmds.get(cmd)?.exec(getArgs(startIndex + 2));
} else {
throw new Error(`Command ${cmd} not supported`);
}

62
bin/cli/worker/cli.worker.js

@ -0,0 +1,62 @@
const fs = require('fs');
const path = require('path');
function scanAndCreate(structure, root = process.cwd()) {
Object.keys(structure)
.forEach(name => {
if (typeof structure[name] === 'object') {
fs.mkdirSync(path.resolve(root, name));
scanAndCreate(structure[name], path.resolve(root, `./${name}`));
} else if (structure[name] === '') {
fs.appendFileSync(path.resolve(root, name), '');
} else if (typeof structure[name] === 'string') {
const content = fs.readFileSync(structure[name]).toString();
fs.appendFileSync(path.resolve(root, name), content);
}
});
}
module.exports = {
exec: async args => {
if (!args.init) {
throw new Error(`Command init not found in args`);
}
if (!args.name) {
throw new Error('Command --name=... not found in args');
}
const name = args.name;
const structure = {
[`${name}_worker`]: {
'main_thread': {
action: {},
[`${name}_main_thread.ts`]: path.resolve(__dirname, './template/main_thread_template.ts'),
},
utils: {
'action_type.ts': '',
},
'worker_thread': {
action: {},
[`${name}_worker_thread.ts`]: path.resolve(__dirname, './template/worker_thread_template.ts'),
},
},
};
scanAndCreate(structure);
},
};
// 结构
// -xxx_worker
// -|--main_thread
// -|--|--action
// -|--|--xxx_main_thread.ts
// -|--utils
// -|--|--action_type.ts
// -|--worker_thread
// -|--|--action
// -|--|--worker_main_thread.ts

0
bin/cli/worker/template/action_type.ts

5
bin/cli/worker/template/main_thread_template.ts

@ -0,0 +1,5 @@
class CrudMainTreadWorker extends BI.Workers.MainThreadWorker {
protected initActions(): void {
// to init some actions
}
}

5
bin/cli/worker/template/worker_thread_template.ts

@ -0,0 +1,5 @@
class CrudWorkerTreadWorker extends BI.Workers.MainThreadWorker {
protected initActions(): void {
// to init some actions
}
}

5
package.json

@ -1,9 +1,12 @@
{
"name": "fineui",
"version": "2.0.20220705215329",
"version": "2.0.20220708100426",
"description": "fineui",
"main": "dist/fineui_without_conflict.min.js",
"types": "dist/lib/index.d.ts",
"bin": {
"fui-cli": "./bin/cli/cli.js"
},
"devDependencies": {
"@babel/core": "^7.17.4",
"@babel/polyfill": "7.6.0",

1
src/widget/dynamicdate/dynamicdate.combo.js

@ -120,6 +120,7 @@ BI.DynamicDateCombo = BI.inherit(BI.Single, {
}, {
eventName: BI.DynamicDateTrigger.EVENT_VALID,
action: function () {
self.storeValue = self.trigger.getValue();
self.combo.element.removeClass("error");
self.fireEvent(BI.DynamicDateCombo.EVENT_VALID);
}

Loading…
Cancel
Save