aiot-toolkit 1.0.18-aspect-beta.15 → 1.0.18-aspect-beta.16
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 +6 -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,11 @@ program
|
|
|
410
410
|
colorconsole.error(error.message)
|
|
411
411
|
}
|
|
412
412
|
})
|
|
413
|
+
// 转换项目类型
|
|
414
|
+
program.command('transform').action(async options => {
|
|
415
|
+
const { transformProject } = require('../lib/commands/transform')
|
|
416
|
+
await transformProject()
|
|
417
|
+
})
|
|
413
418
|
|
|
414
419
|
program.on('--help', () => {
|
|
415
420
|
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"),_inquirer=_interopRequireDefault(require("inquirer"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const oldProjectPath=process.cwd();let projectName="xapp-multi-screen-demo",projectPackageName="com.mi.xapp-multi-screen-demo",newProjectName=`xapp-${projectName}`,newProjectPath=_path.default.join(_path.default.dirname(oldProjectPath),newProjectName);function readName(){const e=_path.default.join(oldProjectPath,"src","manifest.json"),t=_fsExtra.default.readJsonSync(e,{encoding:"utf-8"});if(!t.name||!t.package)throw new Error("The name and package name fields do not exist in the manifest.json!");projectName=t.name,projectPackageName=t.package}async function transformToNewProject(){newProjectName=`xapp-${projectName}`,newProjectPath=_path.default.join(_path.default.dirname(oldProjectPath),newProjectName),await createNewXappProject(),renderFilesData();const e=_path.default.join(oldProjectPath,"src"),t=_path.default.join(newProjectPath,"main","src");await(0,_init.copyFiles)(t,e,{"app.ux":"aspect.ux"})}async function createNewXappProject(){const e=_template.default.app.xappMultiScreenTemplate;for(;_fsExtra.default.existsSync(newProjectPath);){const e=await _inquirer.default.prompt([{type:"input",name:"name",message:`${newProjectName} folder already exists, Please enter new one: `}]);newProjectName=e.name,newProjectPath=_path.default.join(_path.default.dirname(newProjectPath),newProjectName)}_fsExtra.default.mkdirSync(newProjectPath),await(0,_init.copyFiles)(newProjectPath,e,{_gitignore:".gitignore"})}function renderFilesData(){const e={appName:newProjectName,packageName:projectPackageName,toolkitVersion:require("../../package.json").version};["package.json","app/manifest.json",".project.json","README.md"].map((e=>_path.default.join(newProjectPath,e))).forEach((t=>{let a=_fsExtra.default.readFileSync(t,"utf-8");a=(0,_sharedUtils.renderString)(a,e),_fsExtra.default.writeFileSync(t,a)}))}module.exports.transformProject=async function(){readName();try{await transformToNewProject()}catch(e){throw new Error("transform failed!")}_sharedUtils.colorconsole.info(`transform success! new project name is ${newProjectName}, path is ${newProjectPath}`)};
|
|
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.16",
|
|
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.16",
|
|
10
|
+
"@aiot-toolkit/debugger": "1.0.18-aspect-beta.16",
|
|
11
|
+
"@aiot-toolkit/dsl-vue": "1.0.18-aspect-beta.16",
|
|
12
|
+
"@aiot-toolkit/dsl-xvm": "1.0.18-aspect-beta.16",
|
|
13
|
+
"@aiot-toolkit/packager": "1.0.18-aspect-beta.16",
|
|
14
|
+
"@aiot-toolkit/server": "1.0.18-aspect-beta.16",
|
|
15
|
+
"@aiot-toolkit/shared-utils": "1.0.18-aspect-beta.16",
|
|
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": "e13125e632f09f67226658a0ecf93a5bbf4ba6e7"
|
|
55
55
|
}
|