aiot-toolkit 1.0.18-aspect-beta.15 → 1.0.18-aspect-beta.17
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/bin/index.js +9 -1
- package/gen-webpack-conf/index.js +2 -0
- package/lib/commands/init.js +1 -1
- package/lib/commands/transform.js +2 -0
- package/lib/utils.js +1 -1
- package/package.json +9 -9
package/bin/index.js
CHANGED
|
@@ -45,7 +45,7 @@ program
|
|
|
45
45
|
.option('-s --slience', 'Enable silent mode for xapp application creation')
|
|
46
46
|
.description('create a new project.')
|
|
47
47
|
.action((name, options) => {
|
|
48
|
-
const generate = require('../lib/commands/init')
|
|
48
|
+
const { generate } = require('../lib/commands/init')
|
|
49
49
|
generate(name, options)
|
|
50
50
|
})
|
|
51
51
|
|
|
@@ -410,6 +410,14 @@ program
|
|
|
410
410
|
colorconsole.error(error.message)
|
|
411
411
|
}
|
|
412
412
|
})
|
|
413
|
+
// 转换项目类型
|
|
414
|
+
program
|
|
415
|
+
.command('transform [projectPath]')
|
|
416
|
+
.option('-I --import <value>', 'import quickapp as aspect project')
|
|
417
|
+
.action(async (projectPath, options) => {
|
|
418
|
+
const { transformProject } = require('../lib/commands/transform')
|
|
419
|
+
await transformProject(projectPath, options)
|
|
420
|
+
})
|
|
413
421
|
|
|
414
422
|
program.on('--help', () => {
|
|
415
423
|
console.log()
|
|
@@ -176,6 +176,8 @@ module.exports = function genWebpackConf(launchOptions, mode) {
|
|
|
176
176
|
const { deviceTypeList } = manifest
|
|
177
177
|
if (deviceTypeList && deviceTypeList.includes('watch')) {
|
|
178
178
|
initCompileOptionsObject({ enableMirtos: true })
|
|
179
|
+
} else {
|
|
180
|
+
initCompileOptionsObject({ enableMirtos: false })
|
|
179
181
|
}
|
|
180
182
|
|
|
181
183
|
// 设置合适的v8版本
|
package/lib/commands/init.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _path=_interopRequireDefault(require("path")),_fsExtra=_interopRequireDefault(require("fs-extra")),_glob=_interopRequireDefault(require("glob")),_inquirer=_interopRequireDefault(require("inquirer")),_chalk=_interopRequireDefault(require("chalk")),_sharedUtils=require("@aiot-toolkit/shared-utils"),_template=_interopRequireDefault(require("@aiot-toolkit/dsl-xvm/lib/template")),_template2=_interopRequireDefault(require("@aiot-toolkit/dsl-vue/lib/template")),_utils=require("@aiot-toolkit/compiler/lib/utils");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const multiDeviceType="xapp",multiDeviceDemoArray=["xappXapp","xappAspect","xappMultiScreen"],allSupportedDeviceArray=["phone","tv","car","watch","tv-h5","xapp"],allSupportedDevicesString=allSupportedDeviceArray.join(",");async function generate(e,t){""===e&&(e="HelloWorld");const a=!0===t.slience&&"xapp"===t.deviceType,i=a?{name:e}:await _inquirer.default.prompt([{type:"input",name:"name",message:"Init your project",default:e}]),r=_path.default.join(process.cwd(),i.name);try{await createProject(i.name,r,t)}catch(i){_sharedUtils.colorconsole.error(i.message),i.message.match(/Please pick a new name/)&&(a?process.exit():await generate(e,t))}}async function createProject(e,t,a={}){if(_fsExtra.default.existsSync(t))throw new Error(`"${t}" exists! Please pick a new name.`);if(!(0,_sharedUtils.mkdirsSync)(t))throw new Error('failed to created folder "'+t+'"!.');const{dsl:i,deviceType:r,templateType:l,web:o,minaH5:p,minaTv:n}=a;let s="",c="";if(l&&!r)throw new Error("there is no deviceType specified");s=(0,_utils.hyphenedToCamelCase)(`${r}-${l}`),c=multiDeviceDemoArray.find((e=>e===s))||"";let u=["phone"];if(n&&(u=["tv-quickapp"]),p&&(u=["tv-h5"]),r&&r.length>0){const e=r.split(",");let t=new Set,a=new Set;e.map((e=>{e=e.toLowerCase();allSupportedDeviceArray.includes(e)||a.add(e),t.add(e)})),u=Array.from(t),a.size>0&&(_sharedUtils.colorconsole.warn(`These device types have not been officially supported by Quickapp: "${Array.from(a).join(",")}"`),_sharedUtils.colorconsole.warn(`Now Quickapp officially supports device types: "${allSupportedDevicesString}"`))}let d=null,f=null;switch(i){case"vue":d=_template2.default.app.demo,f=_template2.default.app.deviceJsonTemplate;break;default:d=o?_template.default.app.webDemo:p?_template.default.app.minaH5Demo:n?_template.default.app.minaTvDemo:s&&_template.default.app[s]?_template.default.app[s]:u.includes("watch")?_template.default.app.velaDemo:_template.default.app.demo,f=_template.default.app.deviceJsonTemplate}const m=_path.default.resolve(__dirname,d);await copyFiles(t,m,{_gitignore:".gitignore"});const _={appName:e,toolkitVersion:require("../../package.json").version},h={minaH5Demo:["manifest.json","package.json"],xappXapp:["app/manifest.json","package.json",".project.json"],xappAspect:["src/manifest.json","config.json"],xappMultiScreen:["app/manifest.json","package.json",".project.json"],default:["src/manifest.json","package.json"]};(p?h.minaH5Demo:c?h[c]:h.default).map((e=>_path.default.join(t,e))).forEach((e=>{let t=_fsExtra.default.readFileSync(e,"utf-8");if(t=(0,_sharedUtils.renderString)(t,_),e.includes("manifest.json")&&!c){let e=JSON.parse(t.toString());e.deviceTypeList=u,t=JSON.stringify(e,null,2)}_fsExtra.default.writeFileSync(e,t)})),p||c||u.map((a=>{const i=`config-${a}.json`,r=_path.default.join(f,i);let l="{}";_fsExtra.default.existsSync(r)&&(l=_fsExtra.default.readFileSync(r,"utf-8")),console.log(`${e}/src/${i} created`),_fsExtra.default.writeFileSync(_path.default.join(t,`src/config-${a}.json`),l)}))}function copyFiles(e,t,a){const i=_path.default.join(t,"**/{*,.*}"),r=_glob.default.sync(i,{nodir:!0,dot:!0}).map((i=>new Promise((r=>{const l=_path.default.relative(t,i),o=_path.default.join(e,a[l]||l);_fsExtra.default.existsSync(o)?r(_chalk.default.yellow(`${(0,_sharedUtils.relateCwd)(o)} already existed.`)):(r(`${(0,_sharedUtils.relateCwd)(o)} created.`),_fsExtra.default.copySync(i,o))}))));return Promise.all(r).then((e=>{console.log(e.join("\n"))}))}module.exports=generate;
|
|
1
|
+
"use strict";var _path=_interopRequireDefault(require("path")),_fsExtra=_interopRequireDefault(require("fs-extra")),_glob=_interopRequireDefault(require("glob")),_inquirer=_interopRequireDefault(require("inquirer")),_chalk=_interopRequireDefault(require("chalk")),_sharedUtils=require("@aiot-toolkit/shared-utils"),_template=_interopRequireDefault(require("@aiot-toolkit/dsl-xvm/lib/template")),_template2=_interopRequireDefault(require("@aiot-toolkit/dsl-vue/lib/template")),_utils=require("@aiot-toolkit/compiler/lib/utils");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const multiDeviceType="xapp",multiDeviceDemoArray=["xappXapp","xappAspect","xappMultiScreen"],allSupportedDeviceArray=["phone","tv","car","watch","tv-h5","xapp"],allSupportedDevicesString=allSupportedDeviceArray.join(",");async function generate(e,t){""===e&&(e="HelloWorld");const a=!0===t.slience&&"xapp"===t.deviceType,i=a?{name:e}:await _inquirer.default.prompt([{type:"input",name:"name",message:"Init your project",default:e}]),r=_path.default.join(process.cwd(),i.name);try{await createProject(i.name,r,t)}catch(i){_sharedUtils.colorconsole.error(i.message),i.message.match(/Please pick a new name/)&&(a?process.exit():await generate(e,t))}}async function createProject(e,t,a={}){if(_fsExtra.default.existsSync(t))throw new Error(`"${t}" exists! Please pick a new name.`);if(!(0,_sharedUtils.mkdirsSync)(t))throw new Error('failed to created folder "'+t+'"!.');const{dsl:i,deviceType:r,templateType:l,web:o,minaH5:p,minaTv:n}=a;let s="",c="";if(l&&!r)throw new Error("there is no deviceType specified");s=(0,_utils.hyphenedToCamelCase)(`${r}-${l}`),c=multiDeviceDemoArray.find((e=>e===s))||"";let u=["phone"];if(n&&(u=["tv-quickapp"]),p&&(u=["tv-h5"]),r&&r.length>0){const e=r.split(",");let t=new Set,a=new Set;e.map((e=>{e=e.toLowerCase();allSupportedDeviceArray.includes(e)||a.add(e),t.add(e)})),u=Array.from(t),a.size>0&&(_sharedUtils.colorconsole.warn(`These device types have not been officially supported by Quickapp: "${Array.from(a).join(",")}"`),_sharedUtils.colorconsole.warn(`Now Quickapp officially supports device types: "${allSupportedDevicesString}"`))}let d=null,f=null;switch(i){case"vue":d=_template2.default.app.demo,f=_template2.default.app.deviceJsonTemplate;break;default:d=o?_template.default.app.webDemo:p?_template.default.app.minaH5Demo:n?_template.default.app.minaTvDemo:s&&_template.default.app[s]?_template.default.app[s]:u.includes("watch")?_template.default.app.velaDemo:_template.default.app.demo,f=_template.default.app.deviceJsonTemplate}const m=_path.default.resolve(__dirname,d);await copyFiles(t,m,{_gitignore:".gitignore"});const _={appName:e,toolkitVersion:require("../../package.json").version},h={minaH5Demo:["manifest.json","package.json"],xappXapp:["app/manifest.json","package.json",".project.json"],xappAspect:["src/manifest.json","config.json"],xappMultiScreen:["app/manifest.json","package.json",".project.json"],default:["src/manifest.json","package.json"]};(p?h.minaH5Demo:c?h[c]:h.default).map((e=>_path.default.join(t,e))).forEach((e=>{let t=_fsExtra.default.readFileSync(e,"utf-8");if(t=(0,_sharedUtils.renderString)(t,_),e.includes("manifest.json")&&!c){let e=JSON.parse(t.toString());e.deviceTypeList=u,t=JSON.stringify(e,null,2)}_fsExtra.default.writeFileSync(e,t)})),p||c||u.map((a=>{const i=`config-${a}.json`,r=_path.default.join(f,i);let l="{}";_fsExtra.default.existsSync(r)&&(l=_fsExtra.default.readFileSync(r,"utf-8")),console.log(`${e}/src/${i} created`),_fsExtra.default.writeFileSync(_path.default.join(t,`src/config-${a}.json`),l)}))}function copyFiles(e,t,a){const i=_path.default.join(t,"**/{*,.*}"),r=_glob.default.sync(i,{nodir:!0,dot:!0}).map((i=>new Promise((r=>{const l=_path.default.relative(t,i),o=_path.default.join(e,a[l]||l);_fsExtra.default.existsSync(o)?r(_chalk.default.yellow(`${(0,_sharedUtils.relateCwd)(o)} already existed.`)):(r(`${(0,_sharedUtils.relateCwd)(o)} created.`),_fsExtra.default.copySync(i,o))}))));return Promise.all(r).then((e=>{console.log(e.join("\n"))}))}module.exports={generate:generate,copyFiles:copyFiles};
|
|
2
2
|
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var _path=_interopRequireDefault(require("path")),_fsExtra=_interopRequireDefault(require("fs-extra")),_init=require("../../lib/commands/init"),_template=_interopRequireDefault(require("@aiot-toolkit/dsl-xvm/lib/template")),_sharedUtils=require("@aiot-toolkit/shared-utils");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function validateProjectPath(e,t){const a=_path.default.join(e,t);if(!_fsExtra.default.existsSync(a))throw new Error(`Path: ${a} is not exist!`);return a}function readName(e){const t=_path.default.join(e,"src","manifest.json"),a=_fsExtra.default.readJsonSync(t,{encoding:"utf-8"});if(a.name&&a.package)return{projectName:a.name,projectPackageName:a.package};throw new Error("The name and package name fields do not exist in the manifest.json!")}async function transformToNewProject(e){e=validateProjectPath(process.cwd(),e);const t=_path.default.join(_path.default.dirname(e),`xapp-${_path.default.basename(e)}`),{projectName:a,projectPackageName:r}=readName(e);await createNewXappProject(_template.default.app.xappMultiScreenTemplate,t),renderFilesData(t,a,r);const o=_path.default.join(e,"src"),n=_path.default.join(t,"main","src");await(0,_init.copyFiles)(n,o,{"app.ux":"aspect.ux"}),_sharedUtils.colorconsole.info(`transform success! new project path is ${t}`)}async function createNewXappProject(e,t){if(_fsExtra.default.existsSync(t))throw new Error(`Create error: Folfer ${_path.default.basename(t)} already exists in path ${_path.default.dirname(t)}`);_fsExtra.default.mkdirSync(t),await(0,_init.copyFiles)(t,e,{_gitignore:".gitignore"})}function renderFilesData(e,t,a){const r={appName:t,packageName:a,toolkitVersion:require("../../package.json").version};["package.json","app/manifest.json",".project.json","README.md"].map((t=>_path.default.join(e,t))).forEach((e=>{let t=_fsExtra.default.readFileSync(e,"utf-8");t=(0,_sharedUtils.renderString)(t,r),_fsExtra.default.writeFileSync(e,t)}))}async function projectToAspect(e){const t=e.import,a=process.cwd(),r=validateProjectPath(a,t),{projectPackageName:o}=readName(r),n=_path.default.join(a,o);await createNewXappProject(_template.default.app.xappAspect,n);const i=_path.default.join(r,"src"),s=_path.default.join(n,"src");_fsExtra.default.emptyDirSync(s),await(0,_init.copyFiles)(s,i,{"app.ux":"aspect.ux"}),updateAppManifest(a,o),_sharedUtils.colorconsole.info(`import success! new aspect name is ${o}`)}function updateAppManifest(e,t){const a=_path.default.join(e,"app","manifest.json"),r=_fsExtra.default.readJSONSync(a,{encoding:"utf-8"}),o={path:`${t}`,devices:["watch"],autoStart:!0};if(!(r&&r.router&&r.router.aspects&&r.router.aspects instanceof Object))throw new Error("router.aspects does not exist or is in the wrong format");r.router.aspects[`${t}`]=[o],_fsExtra.default.writeJSONSync(a,r)}module.exports.transformProject=async function(e,t){try{t&&t.import?await projectToAspect(t):e?await transformToNewProject(e):_sharedUtils.colorconsole.log("transform stop: No valid information entered!")}catch(e){throw new Error(`transform failed! ${e}`)}};
|
|
2
|
+
//# sourceMappingURL=transform.js.map
|
package/lib/utils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const path=require("path"),{colorconsole:colorconsole}=require("@aiot-toolkit/shared-utils"),{ENTRY_TYPE:ENTRY_TYPE}=require("@aiot-toolkit/packager/lib/common/utils"),{resolveFile:resolveFile}=require("@aiot-toolkit/packager/lib/common/info"),{isEmptyObject:isEmptyObject}=require("@aiot-toolkit/compiler/lib/utils"),globalConfig=require("@aiot-toolkit/shared-utils/config");exports.resolveEntries=function(e,o,t){if(!e.router)throw Error("No routing configured in manifest.json!");const i={},r=e.router.pages||{},s=e.router.widgets||{},l=[{confs:e.router.floatingWindows||{},type:ENTRY_TYPE.FLOAT},{confs:s,type:ENTRY_TYPE.CARD}];l.unshift({confs:r,type:ENTRY_TYPE.PAGE});let n="app";globalConfig.aspectTemplate.isAspect&&!globalConfig.aspectTemplate.isApp&&(n="aspect");const
|
|
1
|
+
"use strict";const path=require("path"),{colorconsole:colorconsole}=require("@aiot-toolkit/shared-utils"),{ENTRY_TYPE:ENTRY_TYPE}=require("@aiot-toolkit/packager/lib/common/utils"),{resolveFile:resolveFile}=require("@aiot-toolkit/packager/lib/common/info"),{isEmptyObject:isEmptyObject}=require("@aiot-toolkit/compiler/lib/utils"),globalConfig=require("@aiot-toolkit/shared-utils/config");exports.resolveEntries=function(e,o,t){if(!e.router)throw Error("No routing configured in manifest.json!");const i={},r=e.router.pages||{},s=e.router.widgets||{},l=[{confs:e.router.floatingWindows||{},type:ENTRY_TYPE.FLOAT},{confs:s,type:ENTRY_TYPE.CARD}];l.unshift({confs:r,type:ENTRY_TYPE.PAGE});let n="app";globalConfig.aspectTemplate.isAspect&&!globalConfig.aspectTemplate.isApp&&(n="aspect");const c=resolveFile(path.join(o,n));c||(colorconsole.error(`${n} file does not exist`),process.exit(1)),i[n]="./"+path.relative(t,c)+`?uxType=${ENTRY_TYPE.APP}`,l.forEach((({confs:e,type:r})=>{Object.keys(e).forEach((s=>{const l=e[s],n=path.join(s,l.component);let c=resolveFile(path.join(o,n));c||colorconsole.throw(`Compilation failed: please confirm that the file path ${n} configured in manifest.json exists`),/^\//.test(s)&&colorconsole.throw(`Compilation failed: please confirm that '${s}' configured by router.pages in manifest.json is the directory name`);let a=path.relative(t,c);a="./"+a+`?uxType=${r}`,a=a.replace(/\\/g,"/"),i[n]=a}))}));const a=e.workers;a&&a.entries&&a.entries instanceof Array&&a.entries.filter((e=>e.file)).forEach((e=>{i[e.file.replace(/\.js$/,"")]="./src/"+e.file}));const p=e.services;if(!isEmptyObject(p))for(const e in p)Object.hasOwnProperty.call(p,e)&&(i["services/"+e]="./src/"+p[e].path+`?uxType=${ENTRY_TYPE.APP}`);return i};
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aiot-toolkit",
|
|
3
|
-
"version": "1.0.18-aspect-beta.
|
|
3
|
+
"version": "1.0.18-aspect-beta.17",
|
|
4
4
|
"description": "A command line toolkit for developing Aiot Quick Apps.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=8.0.0"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@aiot-toolkit/compiler": "1.0.18-aspect-beta.
|
|
10
|
-
"@aiot-toolkit/debugger": "1.0.18-aspect-beta.
|
|
11
|
-
"@aiot-toolkit/dsl-vue": "1.0.18-aspect-beta.
|
|
12
|
-
"@aiot-toolkit/dsl-xvm": "1.0.18-aspect-beta.
|
|
13
|
-
"@aiot-toolkit/packager": "1.0.18-aspect-beta.
|
|
14
|
-
"@aiot-toolkit/server": "1.0.18-aspect-beta.
|
|
15
|
-
"@aiot-toolkit/shared-utils": "1.0.18-aspect-beta.
|
|
9
|
+
"@aiot-toolkit/compiler": "1.0.18-aspect-beta.17",
|
|
10
|
+
"@aiot-toolkit/debugger": "1.0.18-aspect-beta.17",
|
|
11
|
+
"@aiot-toolkit/dsl-vue": "1.0.18-aspect-beta.17",
|
|
12
|
+
"@aiot-toolkit/dsl-xvm": "1.0.18-aspect-beta.17",
|
|
13
|
+
"@aiot-toolkit/packager": "1.0.18-aspect-beta.17",
|
|
14
|
+
"@aiot-toolkit/server": "1.0.18-aspect-beta.17",
|
|
15
|
+
"@aiot-toolkit/shared-utils": "1.0.18-aspect-beta.17",
|
|
16
16
|
"@babel/core": "^7.9.6",
|
|
17
17
|
"@babel/plugin-syntax-jsx": "^7.8.3",
|
|
18
18
|
"@babel/preset-env": "^7.9.6",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"supertest": "^3.3.0",
|
|
52
52
|
"webpack-cli": "^4.3.0"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "18ed4342ef76f52c50fbd30b187127c33ad0c5fc"
|
|
55
55
|
}
|