aiot-toolkit 1.1.0 → 1.1.1-aspect-beta.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ #### [1.1.1] - 2024-05-09
4
+
5
+ - 支持 `internal` 绝对文件路径
6
+ - 增加 `process` 的属性 type 值
7
+ - 优化 `style` 的 class 动态值
8
+
3
9
  #### [1.1.0] - 2024-01-10
4
10
 
5
11
  - 支持 `enable-e2e` 在 server 模式下
package/README.md CHANGED
@@ -41,6 +41,12 @@ npm run release
41
41
 
42
42
  ### 版本日志(详情请在 node_modules 中查看 CHANGELOG)
43
43
 
44
+ #### [1.1.1] - 2024-05-09
45
+
46
+ - 支持 `internal` 绝对文件路径
47
+ - 增加 `process` 的属性 type 值
48
+ - 优化 `style` 的 class 动态值
49
+
44
50
  #### [1.1.0] - 2024-01-10
45
51
 
46
52
  - 支持 `enable-e2e` 在 server 模式下
package/bin/index.js CHANGED
@@ -42,9 +42,10 @@ program
42
42
  '-t --templateType <templateType>',
43
43
  'init project by specific template eg: maml; you should use this with -d'
44
44
  )
45
+ .option('-s --slience', 'Enable silent mode for xapp application creation')
45
46
  .description('create a new project.')
46
47
  .action((name, options) => {
47
- const generate = require('../lib/commands/init')
48
+ const { generate } = require('../lib/commands/init')
48
49
  generate(name, options)
49
50
  })
50
51
 
@@ -90,6 +91,11 @@ program
90
91
  'custom output rpk file name',
91
92
  validateBuildNameFormat
92
93
  )
94
+ .option(
95
+ '--deploy',
96
+ 'compress the device package and manifest.json file in the build into a zip package'
97
+ )
98
+ .option('--output <value>', 'specify the aspect output format')
93
99
  .option('--enable-protobuf', 'use protobuf gen binary.bin file')
94
100
  .action(options => {
95
101
  // 必备参数:当开发者不传递该参数时,要解析为默认
@@ -418,6 +424,14 @@ program
418
424
  colorconsole.error(error.message)
419
425
  }
420
426
  })
427
+ // 转换项目类型
428
+ program
429
+ .command('transform [projectPath]')
430
+ .option('-I --import <value>', 'import quickapp as aspect project')
431
+ .action(async (projectPath, options) => {
432
+ const { transformProject } = require('../lib/commands/transform')
433
+ await transformProject(projectPath, options)
434
+ })
421
435
 
422
436
  program.on('--help', () => {
423
437
  console.log()
@@ -45,14 +45,16 @@ exports.cleanup = function cleanup(BUILD_DIR, DIST_DIR) {
45
45
  * 使用 node 原生模块给予警告
46
46
  */
47
47
  exports.checkBuiltinModules = function checkBuiltinModules({ request }, callback) {
48
- const packageJson = require(path.join(globalConfig.projectPath, 'package.json'))
49
48
  // 提取 package.json 中的依赖
50
49
  let projectDependencies = []
51
- if (packageJson.devDependencies) {
52
- projectDependencies = Object.keys(packageJson.devDependencies)
53
- }
54
- if (packageJson.dependencies) {
55
- projectDependencies = projectDependencies.concat(Object.keys(packageJson.dependencies))
50
+ if (!globalConfig.aspectTemplate.isAspect) {
51
+ const packageJson = require(path.join(globalConfig.projectPath, 'package.json'))
52
+ if (packageJson.devDependencies) {
53
+ projectDependencies = Object.keys(packageJson.devDependencies)
54
+ }
55
+ if (packageJson.dependencies) {
56
+ projectDependencies = projectDependencies.concat(Object.keys(packageJson.dependencies))
57
+ }
56
58
  }
57
59
 
58
60
  // 枚举 node 原生模块
@@ -107,7 +109,12 @@ exports.checkBuiltinModules = function checkBuiltinModules({ request }, callback
107
109
  * @param {boolean} disableScriptV8V65
108
110
  */
109
111
  exports.setAdaptForV8Version = function setAdaptForV8Version(disableScriptV8V65, manifest, cwd) {
110
- const packageJsonFile = path.resolve(cwd, 'package.json')
112
+ let packageJsonFile
113
+ if (globalConfig.aspectTemplate.isAspect) {
114
+ packageJsonFile = path.resolve(globalConfig.aspectTemplate.projectPath, 'package.json')
115
+ } else {
116
+ packageJsonFile = path.resolve(cwd, 'package.json')
117
+ }
111
118
  const packageJson = readJson(packageJsonFile)
112
119
  const minPlatformVersion = parseInt(manifest.minPlatformVersion)
113
120
  if (fs.existsSync(packageJsonFile)) {
@@ -100,7 +100,7 @@ module.exports = function genWebpackConf(launchOptions, mode) {
100
100
  // 是否需要设置全局的打包模式为mina-h5
101
101
  const manifestFileTemp = path.resolve(cwd, 'manifest.json')
102
102
  let isMinaH5 = false
103
- if (fs.existsSync(manifestFileTemp)) {
103
+ if (fs.existsSync(manifestFileTemp) && !globalConfig.aspectTemplate.isAspect) {
104
104
  const manifestTemp = readJson(manifestFileTemp)
105
105
  const { deviceTypeList } = manifestTemp
106
106
  const minaH5Type = ['tv', 'tv-h5']
@@ -116,9 +116,25 @@ module.exports = function genWebpackConf(launchOptions, mode) {
116
116
  // 签名文件目录
117
117
  const SIGN_FOLDER = globalConfig.signRoot
118
118
  // 编译文件的目录
119
- const BUILD_DIR = path.resolve(cwd, globalConfig.outputPath)
119
+ let BUILD_DIR
120
120
  // 最终发布目录:setPreviewPkgPathDir为ide传入的路径,用来保存构建的临时预览包
121
- const DIST_DIR = launchOptions.setPreviewPkgPath || path.resolve(cwd, globalConfig.releasePath)
121
+ let DIST_DIR
122
+ if (globalConfig.aspectTemplate.isAspect) {
123
+ BUILD_DIR = path.resolve(globalConfig.aspectTemplate.outputPath, path.basename(cwd))
124
+ DIST_DIR = path.resolve(globalConfig.aspectTemplate.outputPath, '')
125
+ // 打包vela产物时,文件夹名称+.lite
126
+ if (globalConfig.aspectTemplate.packToVela) {
127
+ BUILD_DIR = path.resolve(globalConfig.aspectTemplate.outputPath, `${path.basename(cwd)}.lite`)
128
+ }
129
+ // 清理 BUILD_DIR
130
+ cleanup(BUILD_DIR)
131
+ } else {
132
+ BUILD_DIR = path.resolve(cwd, globalConfig.outputPath)
133
+ DIST_DIR = launchOptions.setPreviewPkgPath || path.resolve(cwd, globalConfig.releasePath)
134
+ // 清理 BUILD_DIR DIST_DIR
135
+ cleanup(BUILD_DIR, DIST_DIR)
136
+ }
137
+
122
138
  // 打包配置文件
123
139
  const manifestFile = path.resolve(SRC_DIR, 'manifest.json')
124
140
 
@@ -131,7 +147,20 @@ module.exports = function genWebpackConf(launchOptions, mode) {
131
147
  validateProject(manifestFile, SRC_DIR)
132
148
 
133
149
  // 清理 BUILD_DIR DIST_DIR
134
- cleanup(BUILD_DIR, DIST_DIR)
150
+ // cleanup(BUILD_DIR, DIST_DIR)
151
+
152
+ // 将aspect文件夹的config.json文件复制到build文件夹
153
+ if (globalConfig.aspectTemplate.isAspect && !globalConfig.aspectTemplate.isApp) {
154
+ const configJSON = path.join(cwd, 'config.json')
155
+ if (fs.existsSync(configJSON)) {
156
+ const sourceStream = fs.createReadStream(configJSON)
157
+ const targetStream = fs.createWriteStream(path.join(BUILD_DIR, path.basename(configJSON)))
158
+
159
+ sourceStream.pipe(targetStream)
160
+ } else {
161
+ colorconsole.log(`The path of project ,${configJSON} not exist`)
162
+ }
163
+ }
135
164
 
136
165
  let manifest
137
166
  try {
@@ -139,17 +168,28 @@ module.exports = function genWebpackConf(launchOptions, mode) {
139
168
  } catch (e) {
140
169
  throw new KnownError('manifest.json parsing failed!')
141
170
  }
171
+ if (!globalConfig.aspectTemplate.isApp) {
172
+ validateManifest(SRC_DIR, manifest, compileOptionsObject)
142
173
 
143
- validateManifest(SRC_DIR, manifest, compileOptionsObject)
144
-
145
- valiedateSitemap(SRC_DIR, manifest)
174
+ valiedateSitemap(SRC_DIR, manifest)
146
175
 
147
- valiedateSkeleton(SRC_DIR, manifest)
148
-
149
- // 是否需要设置全局的打包模式为Mirtos
150
- const { deviceTypeList } = manifest
151
- if (deviceTypeList && deviceTypeList.includes('watch')) {
152
- initCompileOptionsObject({ enableMirtos: true })
176
+ valiedateSkeleton(SRC_DIR, manifest)
177
+ }
178
+ // 是否需要设置全局的打包模式为Mirtos,先初始化为false
179
+ initCompileOptionsObject({ enableMirtos: false })
180
+ if (globalConfig.aspectTemplate.isAspect) {
181
+ // 避免tv, tv-h5设备干扰打包
182
+ initCompileOptionsObject({ enableMinaH5: false })
183
+ // aspect分布式打包根据参数来判断打包模式
184
+ if (globalConfig.aspectTemplate.packToVela) {
185
+ initCompileOptionsObject({ enableMirtos: true })
186
+ }
187
+ } else {
188
+ // 一般情况下的配置
189
+ const { deviceTypeList } = manifest
190
+ if (deviceTypeList && deviceTypeList.includes('watch')) {
191
+ initCompileOptionsObject({ enableMirtos: true })
192
+ }
153
193
  }
154
194
 
155
195
  // 设置合适的v8版本
@@ -381,15 +421,11 @@ module.exports = function genWebpackConf(launchOptions, mode) {
381
421
  path: pathMap[dslName]
382
422
  })
383
423
 
384
- const {
385
- package: appPackageName,
386
- icon: appIcon,
387
- versionName,
388
- versionCode,
389
- subpackages,
390
- workers,
391
- banner = ''
392
- } = manifest
424
+ const { icon: appIcon, versionName, versionCode, subpackages, workers, banner = '' } = manifest
425
+ let appPackageName = manifest.package
426
+ if (globalConfig.aspectTemplate.isAspect) {
427
+ appPackageName = path.basename(BUILD_DIR)
428
+ }
393
429
  for (let i = 0, len = moduleList.length; i < len; i++) {
394
430
  const fileConf = moduleList[i].path
395
431
  if (fs.existsSync(fileConf)) {
@@ -3,9 +3,10 @@ const path = require('path')
3
3
  const Ajv = require('ajv')
4
4
  const AjvErrors = require('ajv-errors')
5
5
  const manifestSchema = require('./manifest-schema')
6
- const { colorconsole, KnownError } = require('@aiot-toolkit/shared-utils')
6
+ const { colorconsole, KnownError, readJson } = require('@aiot-toolkit/shared-utils')
7
7
  const { compileOptionsMeta } = require('@aiot-toolkit/shared-utils/compilation-config')
8
8
  const { getSkeletonConfig } = require('@aiot-toolkit/packager/lib/common/info')
9
+ const globalConfig = require('@aiot-toolkit/shared-utils/config')
9
10
 
10
11
  // 主包保留名
11
12
  const MAIN_PKG_NAME = compileOptionsMeta.MAIN_PKG_NAME
@@ -282,3 +283,31 @@ exports.valiedateSkeleton = function valiedateSkeleton(src, manifest) {
282
283
  })
283
284
  }
284
285
  }
286
+ /**
287
+ * 校验aspect项目config.json
288
+ * @param {string} dirs 文件夹列表
289
+ */
290
+ exports.validateConfigJson = function(dirs) {
291
+ dirs.forEach(async dir => {
292
+ const configPath = path.join(globalConfig.aspectTemplate.projectPath, dir, 'config.json')
293
+ if (dir !== 'app') {
294
+ const isExistConfig = fs.existsSync(configPath)
295
+ if (isExistConfig) {
296
+ const configJson = await readJson(configPath)
297
+ if (!configJson.name) {
298
+ colorconsole.error(`Configure file ${configPath} error: name is not exist, please check`)
299
+ }
300
+ if (!configJson.type) {
301
+ colorconsole.error(`Configure file ${configPath} error: type is not exist, please check`)
302
+ }
303
+ if (!configJson.virtualMachine) {
304
+ colorconsole.error(
305
+ `Configure file ${configPath} error: virtualMachine is not exist, please check`
306
+ )
307
+ }
308
+ } else {
309
+ colorconsole.error(`Configure file error: ${configPath} is not exist, please check`)
310
+ }
311
+ }
312
+ })
313
+ }
@@ -1,2 +1,2 @@
1
- "use strict";const webpack=require("webpack"),{setCustomConfig:setCustomConfig,colorconsole:colorconsole}=require("@aiot-toolkit/shared-utils"),genWebpackConf=require("../../gen-webpack-conf"),{summaryErrors:summaryErrors,summaryWarnings:summaryWarnings}=require("./utils");let watching=null;function showVersion(){const o=require("../../package.json").version,r=require("@babel/core/package.json").version,e=require("webpack/package.json").version;colorconsole.info(`aiot-toolkit: ${o}; babel: ${r}; webpack: ${e};`)}showVersion(),module.exports.compile=function(o,r,e,s={}){const n=s.onerror;return new Promise(((c,t)=>{function a(o,r){if(o&&(n&&n(o),colorconsole.error(o)),r){if(r.hasErrors()||r.hasWarnings()){const o=summaryErrors(r),e=summaryWarnings(r);n&&n(o),colorconsole.error(o),colorconsole.warn(e)}r.hasErrors()&&(process.exitCode=1)}}colorconsole.attach(s.log),setCustomConfig(s.cwd),process.env.NODE_PLATFORM=o,process.env.NODE_PHASE=r;const i="prod"===r?"production":"development";try{const o=genWebpackConf(s,i);if(e){const r=webpack(o);watching=r.watch({aggregateTimeout:300},((o,r)=>{a(o,r),c({compileError:o,stats:r,watching:watching})}))}else webpack(o,((o,r)=>{a(o,r),c({compileError:o,stats:r})}))}catch(o){t(o)}}))},module.exports.stopWatch=function(){return new Promise((o=>{watching?watching.close((()=>{watching=null,o({stopWatchError:null})})):o({stopWatchError:"no watching"})}))};
1
+ "use strict";var _ziputil=require("@aiot-toolkit/packager/lib/common/ziputil"),_config=_interopRequireDefault(require("@aiot-toolkit/shared-utils/config"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const webpack=require("webpack"),{setCustomConfig:setCustomConfig,colorconsole:colorconsole,getProjectJson:getProjectJson,getManifest:getManifest,readJson:readJson}=require("@aiot-toolkit/shared-utils"),genWebpackConf=require("../../gen-webpack-conf"),{summaryErrors:summaryErrors,summaryWarnings:summaryWarnings,getAspectEntries:getAspectEntries,cleanOrCreateDir:cleanOrCreateDir,copyFiles:copyFiles,getProductionTypes:getProductionTypes,isMirtosDevice:isMirtosDevice,deleteCompressedFiles:deleteCompressedFiles,getAndCopyDeviceAspectResource:getAndCopyDeviceAspectResource}=require("./utils"),{validateConfigJson:validateConfigJson}=require("../../gen-webpack-conf/validate"),path=require("path"),fs=require("fs");let appName,watching=null;function showVersion(){const e=require("../../package.json").version,t=require("@babel/core/package.json").version,o=require("webpack/package.json").version;colorconsole.info(`aiot-toolkit: ${e}; babel: ${t}; webpack: ${o};`)}async function aspectProjectCompiler(e,t,o,a={}){let s=getManifest();appName=s.package||"demo";const{entries:i,deviceAspects:r,routerObj:c}=getAspectEntries(_config.default.aspectTemplate.projectPath,s);validateConfigJson(i);const n=_config.default.aspectTemplate.distPath,p=_config.default.aspectTemplate.outputPath;cleanOrCreateDir(p),cleanOrCreateDir(n);const l=path.join(p,appName),u=[];async function f(s,i,r,c){_config.default.aspectTemplate.outputPath=l,_config.default.sourceRoot="",_config.default.aspectTemplate.isApp=!0,a.cwd=r;const n=getProductionTypes(c);if(s){for(const s of Object.keys(n))if(n[s]){_config.default.aspectTemplate.packToVela="enableMirtos"===s;const i=_config.default.aspectTemplate.packToVela?"app.lite":"app";u.push(i),await singleCompiler(e,t,o,a)}}else _config.default.aspectTemplate.packToVela=i,await singleCompiler(e,t,o,a)}try{const g="rpk"===a.output;if(await async function(s,i,r){for(let c of s){_config.default.aspectTemplate.outputPath=r?p:l,_config.default.sourceRoot="./src",_config.default.aspectTemplate.isApp=!1,a.cwd=path.join(_config.default.aspectTemplate.projectPath,c),_config.default.aspectTemplate.packToVela=!1;let s=path.resolve(a.cwd,_config.default.sourceRoot,"manifest.json");if(!fs.existsSync(s))throw new Error(`the file ${s} cannot be found.`);const n=readJson(s),{deviceTypeList:u}=n;if(u&&Array.isArray(u)){const s=getProductionTypes(u);for(const r of Object.keys(s))if(s[r]){_config.default.aspectTemplate.packToVela="enableMirtos"===r;const s=_config.default.aspectTemplate.packToVela?c+".lite":c;i.push(s),await singleCompiler(e,t,o,a)}}else i.push(c),await singleCompiler(e,t,o,a)}}(i,u,g),g)return deleteCompressedFiles(p,!0,n),a.deploy&&await deployAll("",n,_config.default.aspectTemplate.projectPath),Promise.resolve();c.all=s.router.aspects,r.all=u;const m=path.join(_config.default.aspectTemplate.projectPath,"app"),d=path.join(m,"manifest.json");let h=JSON.parse(JSON.stringify(s));const{deviceTypeList:y}=s,w=path.join(m,".manifest.json");fs.writeFileSync(w,JSON.stringify(s));for(let e of Object.keys(r)){const t=isMirtosDevice(e);let o="all"===e,a=o?appName:appName+"."+e.trim().replace(" ",".");h.router.aspects=c[e],fs.writeFileSync(d,JSON.stringify(h,null,2)),await f(o,t,m,y);let s=[];if(o)for(const t of r[e]){const e="app"===t||"app.lite"===t?t+".base":t+".aspc";s.push({name:t,targetFile:e,otherName:e})}else!g&&r[e].unshift("app"),s=getAndCopyDeviceAspectResource(r[e],l,a,t);const i=".app",p=path.join(n,a+i);await(0,_ziputil.packFolderToApp)(p,s,l)}return deleteCompressedFiles(l),fs.unlinkSync(w),a.deploy&&await deployAll(d,n,_config.default.aspectTemplate.projectPath),Promise.resolve()}catch(e){console.log(`Distributed project compiler error ${e}`)}}function singleCompiler(e,t,o,a={}){const s=a.onerror;return new Promise(((i,r)=>{function c(e,t){if(e&&(s&&s(e),colorconsole.error(e)),t){if(t.hasErrors()||t.hasWarnings()){const e=summaryErrors(t),o=summaryWarnings(t);s&&s(e),colorconsole.error(e),colorconsole.warn(o)}t.hasErrors()&&(process.exitCode=1)}}colorconsole.attach(a.log),setCustomConfig(a.cwd),process.env.NODE_PLATFORM=e,process.env.NODE_PHASE=t;const n="prod"===t?"production":"development";try{const e=genWebpackConf(a,n);if(_config.default.aspectTemplate.isAspect&&"rpk"===a.output&&(e.output.filename=e=>"aspect"===e.chunk.name?"app.js":"[name].js"),o){const t=webpack(e);watching=t.watch({aggregateTimeout:300},((e,t)=>{c(e,t),i({compileError:e,stats:t,watching:watching})}))}else webpack(e,((e,t)=>{c(e,t),i({compileError:e,stats:t})}))}catch(e){console.log(`singleCompiler error ${e}`)}}))}async function deployAll(e,t,o){e&&fs.copyFileSync(e,path.join(t,"manifest.json"));const a=path.join(t,path.basename(o)+".zip"),s=fs.readdirSync(t).map((e=>({name:e,targetFile:e,otherName:e})));await(0,_ziputil.packFolderToApp)(a,s,t)}showVersion(),module.exports.compile=async function(e,t,o,a={}){var s;let i;return"distributed"===(null===(s=getProjectJson())||void 0===s?void 0:s.projectType)?(_config.default.aspectTemplate.isAspect=!0,i=await aspectProjectCompiler(e,t,o,a)):i=await singleCompiler(e,t,o,a),i},module.exports.stopWatch=function(){return new Promise((e=>{watching?watching.close((()=>{watching=null,e({stopWatchError:null})})):e({stopWatchError:"no watching"})}))};
2
2
  //# sourceMappingURL=compile.js.map
@@ -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 allSupportedDeviceArray=["phone","tv","car","watch","tv-h5"],allSupportedDevicesString=allSupportedDeviceArray.join(",");async function generate(e,t){""===e&&(e="HelloWorld");const a=await _inquirer.default.prompt([{type:"input",name:"name",message:"Init your project",default:e}]),r=_path.default.join(process.cwd(),a.name);try{await createProject(a.name,r,t)}catch(a){_sharedUtils.colorconsole.error(a.message),a.message.match(/Please pick a new name/)&&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:r,deviceType:l,templateType:i,web:o,minaH5:n,minaTv:s}=a;let p="";if(i&&!l)throw new Error("there is no deviceType specified");p=(0,_utils.hyphenedToCamelCase)(`${l}-${i}`);let u=["phone"];if(s&&(u=["tv-quickapp"]),n&&(u=["tv-h5"]),l&&l.length>0){const e=l.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 c=null,d=null;switch(r){case"vue":c=_template2.default.app.demo,d=_template2.default.app.deviceJsonTemplate;break;default:c=o?_template.default.app.webDemo:n?_template.default.app.minaH5Demo:s?_template.default.app.minaTvDemo:p&&_template.default.app[p]?_template.default.app[p]:u.includes("watch")?_template.default.app.velaDemo:_template.default.app.demo,d=_template.default.app.deviceJsonTemplate}const f=_path.default.resolve(__dirname,c);await copyFiles(t,f,{_gitignore:".gitignore"});const _={appName:e,toolkitVersion:require("../../package.json").version};(n?["package.json","manifest.json"]:["src/manifest.json","package.json"]).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")){let e=JSON.parse(t.toString());e.deviceTypeList=u,e.minAPILevel=1,t=JSON.stringify(e,null,2)}_fsExtra.default.writeFileSync(e,t)})),n||u.map((a=>{const r=`config-${a}.json`,l=_path.default.join(d,r);let i="{}";_fsExtra.default.existsSync(l)&&(i=_fsExtra.default.readFileSync(l,"utf-8")),console.log(`${e}/src/${r} created`),_fsExtra.default.writeFileSync(_path.default.join(t,`src/config-${a}.json`),i)}))}function copyFiles(e,t,a){const r=_path.default.join(t,"**/{*,.*}"),l=_glob.default.sync(r,{nodir:!0,dot:!0}).map((r=>new Promise((l=>{const i=_path.default.relative(t,r),o=_path.default.join(e,a[i]||i);_fsExtra.default.existsSync(o)?l(_chalk.default.yellow(`${(0,_sharedUtils.relateCwd)(o)} already existed.`)):(l(`${(0,_sharedUtils.relateCwd)(o)} created.`),_fsExtra.default.copySync(r,o))}))));return Promise.all(l).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,e.minAPILevel=1,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,dirName:_path.default.basename(e)};["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),{projectName:o,projectPackageName:n}=readName(r),i=_path.default.join(a,n);await createNewXappProject(_template.default.app.xappAspect,i);const s={appName:o},c=_path.default.join(i,"config.json");let p=_fsExtra.default.readFileSync(c,"utf-8");p=(0,_sharedUtils.renderString)(p,s),_fsExtra.default.writeFileSync(c,p);const f=_path.default.join(r,"src"),l=_path.default.join(i,"src");_fsExtra.default.emptyDirSync(l),await(0,_init.copyFiles)(l,f,{"app.ux":"aspect.ux"}),updateAppManifest(a,n),_sharedUtils.colorconsole.info(`import success! new aspect name is ${n}`)}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,{spaces:2})}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
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.formatDate=formatDate,exports.summaryErrors=summaryErrors,exports.summaryWarnings=summaryWarnings,exports.getQuickappDebuggerUrl=getQuickappDebuggerUrl,exports.getQuickappPreviewUrl=getQuickappPreviewUrl,exports.downloadFile=downloadFile,exports.sendReq=sendReq,exports.getClients=getClients,exports.checkQuickappDir=checkQuickappDir,exports.getCardContent=getCardContent;var _fsExtra=_interopRequireDefault(require("fs-extra")),_path=_interopRequireDefault(require("path")),_request=_interopRequireDefault(require("request")),_http=_interopRequireDefault(require("http")),_recordClient=require("@aiot-toolkit/shared-utils/lib/record-client"),_config=require("@aiot-toolkit/shared-utils/config"),_sharedUtils=require("@aiot-toolkit/shared-utils");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function formatDate(e,t){let r,o,s,n,i,a,l=e;return(e.indexOf("yyyy")>=0||e.indexOf("YYYYY")>=0)&&(r=t.getFullYear(),l=l.replace(/[yY]{4}/g,r)),e.indexOf("MM")>=0&&(o=t.getMonth()+1,l=l.replace(/MM/g,String(o).length<2?"0"+o:o)),e.indexOf("dd")>=0&&(s=t.getDate(),l=l.replace(/dd/g,String(s).length<2?"0"+s:s)),(e.indexOf("hh")>=0||e.indexOf("HH")>=0)&&(n=t.getHours(),l=l.replace(/[hH]{2}/g,String(n).length<2?"0"+n:n)),e.indexOf("mm")>=0&&(i=t.getMinutes(),l=l.replace(/mm/g,String(i).length<2?"0"+i:i)),(e.indexOf("ss")>=0||e.indexOf("SS")>=0)&&(a=t.getSeconds(),l=l.replace(/[sS]{2}/g,String(a).length<2?"0"+a:a)),l}function summaryErrors(e){const t=[];return e.compilation.errors.forEach((e=>{const r=e.message,o=/Can't resolve '(sass-loader|less-loader|stylus-loader)'/.exec(r);if("ModuleNotFoundError"===e.name&&o){let t=o[1];"less-loader"===t?t=`less ${t}`:"sass-loader"===t?t=`sass ${t}`:"stylus-loader"===t&&(t=`stylus ${t}`),e.message=` Missing dependency: ${t}, Please execute npm install -D ${t} to install the corresponding dependencies `}const s=e.module?e.module.resource:"";t.push(`${s}\r\n${e.message}`)})),t.join("\n\n")}function summaryWarnings(e){return e.compilation.warnings.map((e=>e.message)).join("\n\n")}const quickapp_url="https://statres.quickapp.cn/quickapp/quickapptool/release/platform/";function getQuickappDebuggerUrl(e){let t=e||"v1080";return _sharedUtils.colorconsole.log(`The version of the Quickapp debugger that started to download is: ${t}`),`${quickapp_url}quickapp_debugger_${t}.apk`}function getQuickappPreviewUrl(e){let t=e||"v1080";return _sharedUtils.colorconsole.log(`The version of the Quickapp debugger that started to download is: ${t}`),`${quickapp_url}quickapp_platform_preview_release_${t}.apk`}function downloadFile(e,t){return _sharedUtils.colorconsole.log(`Start downloading file:${t}, address:${e}`),new Promise((function(r,o){(0,_request.default)(e,(function(s,n,i){if(s||200!==n.statusCode)o(s||new Error(`Download failed, status code:${n.statusCode}`));else{const s=_path.default.join(__dirname,"./apk");_fsExtra.default.ensureDirSync(s);let n=_fsExtra.default.createWriteStream(_path.default.join(s,t));(0,_request.default)(e).pipe(n).on("close",(e=>{e?o(e):r(`Download file ${t} successfully`)}))}}))}))}async function sendReq(e,t,r){return new Promise((o=>{const s=`http://${e.ip}:${e.port}${t}`;let n={host:e.ip,port:e.port,path:t,timeout:3e3};r&&(n=Object.assign({},n,{headers:r}));const i=_http.default.request(n,(e=>{e.on("data",(e=>{_sharedUtils.colorconsole.log(`### App Server ### Request ${s} succeeded`),o(e.toString())}))})).on("error",(e=>{_sharedUtils.colorconsole.error(`### App Server ### Request ${s} error message: ${e.message}`)})).on("timeout",(function(){_sharedUtils.colorconsole.log(`### App Server ### Request ${s} timed out, please try again`),i.abort()}));i.end()}))}async function getClients(){return new Promise((e=>{if(_fsExtra.default.existsSync(_config.clientRecordPath)){const t=(0,_recordClient.getRecords)(_config.clientRecordPath),r=(0,_recordClient.getProjectClients)(t);r.length>0&&e(r)}e(null)}))}function checkQuickappDir(e,t="src"){const r=_path.default.join(e,t,"manifest.json");_fsExtra.default.existsSync(r)||(_sharedUtils.colorconsole.error("Please execute this command under the Quickapp project"),process.exit())}function getCardContent(e){const t=_path.default.join(e,"src","manifest.json"),r=(0,_sharedUtils.readJson)(t).router.widgets||null;return r||_sharedUtils.colorconsole.error("No card configuration in manifest.json"),r}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.formatDate=formatDate,exports.summaryErrors=summaryErrors,exports.summaryWarnings=summaryWarnings,exports.getQuickappDebuggerUrl=getQuickappDebuggerUrl,exports.getQuickappPreviewUrl=getQuickappPreviewUrl,exports.downloadFile=downloadFile,exports.sendReq=sendReq,exports.getClients=getClients,exports.checkQuickappDir=checkQuickappDir,exports.getCardContent=getCardContent,exports.cleanOrCreateDir=cleanOrCreateDir,exports.getAspectEntries=getAspectEntries,exports.copyFiles=copyFiles,exports.getProductionTypes=getProductionTypes,exports.isMirtosDevice=isMirtosDevice,exports.deleteCompressedFiles=deleteCompressedFiles,exports.getAndCopyDeviceAspectResource=getAndCopyDeviceAspectResource;var _fsExtra=_interopRequireDefault(require("fs-extra")),_path=_interopRequireDefault(require("path")),_request=_interopRequireDefault(require("request")),_http=_interopRequireDefault(require("http")),_recordClient=require("@aiot-toolkit/shared-utils/lib/record-client"),_config=require("@aiot-toolkit/shared-utils/config"),_sharedUtils=require("@aiot-toolkit/shared-utils");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const fsExtra=require("fs-extra");function formatDate(e,t){let r,o,s,n,i,a,c=e;return(e.indexOf("yyyy")>=0||e.indexOf("YYYYY")>=0)&&(r=t.getFullYear(),c=c.replace(/[yY]{4}/g,r)),e.indexOf("MM")>=0&&(o=t.getMonth()+1,c=c.replace(/MM/g,String(o).length<2?"0"+o:o)),e.indexOf("dd")>=0&&(s=t.getDate(),c=c.replace(/dd/g,String(s).length<2?"0"+s:s)),(e.indexOf("hh")>=0||e.indexOf("HH")>=0)&&(n=t.getHours(),c=c.replace(/[hH]{2}/g,String(n).length<2?"0"+n:n)),e.indexOf("mm")>=0&&(i=t.getMinutes(),c=c.replace(/mm/g,String(i).length<2?"0"+i:i)),(e.indexOf("ss")>=0||e.indexOf("SS")>=0)&&(a=t.getSeconds(),c=c.replace(/[sS]{2}/g,String(a).length<2?"0"+a:a)),c}function summaryErrors(e){const t=[];return e.compilation.errors.forEach((e=>{const r=e.message,o=/Can't resolve '(sass-loader|less-loader|stylus-loader)'/.exec(r);if("ModuleNotFoundError"===e.name&&o){let t=o[1];"less-loader"===t?t=`less ${t}`:"sass-loader"===t?t=`sass ${t}`:"stylus-loader"===t&&(t=`stylus ${t}`),e.message=` Missing dependency: ${t}, Please execute npm install -D ${t} to install the corresponding dependencies `}const s=e.module?e.module.resource:"";t.push(`${s}\r\n${e.message}`)})),t.join("\n\n")}function summaryWarnings(e){return e.compilation.warnings.map((e=>e.message)).join("\n\n")}const quickapp_url="https://statres.quickapp.cn/quickapp/quickapptool/release/platform/";function getQuickappDebuggerUrl(e){let t=e||"v1080";return _sharedUtils.colorconsole.log(`The version of the Quickapp debugger that started to download is: ${t}`),`${quickapp_url}quickapp_debugger_${t}.apk`}function getQuickappPreviewUrl(e){let t=e||"v1080";return _sharedUtils.colorconsole.log(`The version of the Quickapp debugger that started to download is: ${t}`),`${quickapp_url}quickapp_platform_preview_release_${t}.apk`}function downloadFile(e,t){return _sharedUtils.colorconsole.log(`Start downloading file:${t}, address:${e}`),new Promise((function(r,o){(0,_request.default)(e,(function(s,n,i){if(s||200!==n.statusCode)o(s||new Error(`Download failed, status code:${n.statusCode}`));else{const s=_path.default.join(__dirname,"./apk");_fsExtra.default.ensureDirSync(s);let n=_fsExtra.default.createWriteStream(_path.default.join(s,t));(0,_request.default)(e).pipe(n).on("close",(e=>{e?o(e):r(`Download file ${t} successfully`)}))}}))}))}async function sendReq(e,t,r){return new Promise((o=>{const s=`http://${e.ip}:${e.port}${t}`;let n={host:e.ip,port:e.port,path:t,timeout:3e3};r&&(n=Object.assign({},n,{headers:r}));const i=_http.default.request(n,(e=>{e.on("data",(e=>{_sharedUtils.colorconsole.log(`### App Server ### Request ${s} succeeded`),o(e.toString())}))})).on("error",(e=>{_sharedUtils.colorconsole.error(`### App Server ### Request ${s} error message: ${e.message}`)})).on("timeout",(function(){_sharedUtils.colorconsole.log(`### App Server ### Request ${s} timed out, please try again`),i.abort()}));i.end()}))}async function getClients(){return new Promise((e=>{if(_fsExtra.default.existsSync(_config.clientRecordPath)){const t=(0,_recordClient.getRecords)(_config.clientRecordPath),r=(0,_recordClient.getProjectClients)(t);r.length>0&&e(r)}e(null)}))}function checkQuickappDir(e,t="src"){const r=_path.default.join(e,t,"manifest.json");_fsExtra.default.existsSync(r)||(_sharedUtils.colorconsole.error("Please execute this command under the Quickapp project"),process.exit())}function getCardContent(e){const t=_path.default.join(e,"src","manifest.json"),r=(0,_sharedUtils.readJson)(t).router.widgets||null;return r||_sharedUtils.colorconsole.error("No card configuration in manifest.json"),r}function cleanOrCreateDir(e){try{_fsExtra.default.accessSync(e,_fsExtra.default.constants.F_OK),fsExtra.emptyDirSync(e)}catch(t){_fsExtra.default.mkdirSync(e,{recursive:!0})}}function getAspectEntries(e,t){let r=[],o={},s={},n=_fsExtra.default.readdirSync(e,{encoding:"utf8"});const i=_path.default.join(e,"app","manifest.json"),a=t.router.aspects||null,c=Object.keys(a);return t.router||_sharedUtils.colorconsole.error(`Configuration file ${i} error: router is not exsist, please check`),a||_sharedUtils.colorconsole.error(`Configuration file ${i} error: router.aspect is not exist, please check`),c.forEach((e=>{const t=a[e];let c=[];t.forEach((t=>{n.includes(t.path)&&!r.includes(t.path)?r.push(t.path):_sharedUtils.colorconsole.throw(`Configuration file ${i} error: ${t.path} is not exist in root directory`);let a=t.devices?t.devices:["phone"];for(let r=0;r<a.length;r++){let n=[a[r],t.rule?t.rule:""].join(" ");c.includes(n)?_sharedUtils.colorconsole.throw(`Configuration file ${i} error, devices or devices rule: ${n} is repeat in router ${e}`):c.push(n),s[n]=_objectSpread(_objectSpread({},s[n]),{},{[e]:t}),Object.keys(o).includes(n)?o[n].push(t.path):o[n]=[t.path]}}))})),{entries:r,deviceAspects:o,routerObj:s}}function copyFiles(e,t){_fsExtra.default.existsSync(e)||_sharedUtils.colorconsole.throw(`Resource copy error, the path ${e} not exist.`),_fsExtra.default.existsSync(t)||_fsExtra.default.mkdirSync(t,{recursive:!0});_fsExtra.default.readdirSync(e).forEach((r=>{const o=_path.default.join(e,r),s=_path.default.join(t,r);_fsExtra.default.statSync(o).isDirectory()?copyFiles(o,s):_fsExtra.default.copyFileSync(o,s)}))}const mirtosDeviceConfig=["watch"],androidDeviceConfig=[""];function getProductionTypes(e){const t={enableMirtos:!1,enableAndroid:!1};return 0===e.length?t.enableAndroid=!0:e.map((e=>{mirtosDeviceConfig.indexOf(e)>-1?t.enableMirtos=!0:t.enableAndroid=!0})),t}function isMirtosDevice(e){return mirtosDeviceConfig.some((t=>e.includes(t)))}function deleteCompressedFiles(e,t=!1,r=""){const o=[".base",".aspc"];_fsExtra.default.readdirSync(e).forEach((s=>{const{name:n,ext:i}=_path.default.parse(s),a=_path.default.join(e,s);if(_fsExtra.default.statSync(a).isFile()&&o.includes(i.toLowerCase()))if(t){const e=_path.default.join(r,`${n}.rpk`);_fsExtra.default.renameSync(a,e)}else _fsExtra.default.unlinkSync(a)}))}function getAndCopyDeviceAspectResource(e,t,r,o){const s=_path.default.dirname(t);return e.map((e=>{let n=o?`${e}.lite`:e;return copyFiles(_path.default.join(t,n),_path.default.join(s,r,e)),{name:e,targetFile:"app"===e?n+".base":n+".aspc",otherName:"app"===e?e+".base":e+".aspc"}}))}
2
2
  //# sourceMappingURL=utils.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");exports.resolveEntries=function(e,o,t){if(!e.router)throw Error("No routing configured in manifest.json!");const r={},i=e.router.pages||{},s=e.router.widgets||{},n=[{confs:e.router.floatingWindows||{},type:ENTRY_TYPE.FLOAT},{confs:s,type:ENTRY_TYPE.CARD}];n.unshift({confs:i,type:ENTRY_TYPE.PAGE});const c=resolveFile(path.join(o,"app"));c||(colorconsole.error("app file does not exist"),process.exit(1)),r.app="./"+path.relative(t,c)+`?uxType=${ENTRY_TYPE.APP}`,n.forEach((({confs:e,type:i})=>{Object.keys(e).forEach((s=>{const n=e[s],c=path.join(s,n.component),a=resolveFile(path.join(o,c));a||colorconsole.throw(`Compilation failed: please confirm that the file path ${c} 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 l=path.relative(t,a);l="./"+l+`?uxType=${i}`,l=l.replace(/\\/g,"/"),r[c]=l}))}));const a=e.workers;a&&a.entries&&a.entries instanceof Array&&a.entries.filter((e=>e.file)).forEach((e=>{r[e.file.replace(/\.js$/,"")]="./src/"+e.file}));const l=e.services;if(!isEmptyObject(l))if(Array.isArray(l))l.forEach((e=>{const{name:o,path:t}=e;o&&t&&(r["services/"+o]="./src/"+t+`?uxType=${ENTRY_TYPE.APP}`)}));else for(const e in l)Object.hasOwnProperty.call(l,e)&&(r["services/"+e]="./src/"+l[e].path+`?uxType=${ENTRY_TYPE.APP}`);return r};
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))if(Array.isArray(p))p.forEach((e=>{const{name:o,path:t}=e;o&&t&&(i["services/"+o]="./src/"+t+`?uxType=${ENTRY_TYPE.APP}`)}));else 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.1.0",
3
+ "version": "1.1.1-aspect-beta.2",
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.1.0",
10
- "@aiot-toolkit/debugger": "1.1.0",
11
- "@aiot-toolkit/dsl-vue": "1.1.0",
12
- "@aiot-toolkit/dsl-xvm": "1.1.0",
13
- "@aiot-toolkit/packager": "1.1.0",
14
- "@aiot-toolkit/server": "1.1.0",
15
- "@aiot-toolkit/shared-utils": "1.1.0",
9
+ "@aiot-toolkit/compiler": "1.1.1-aspect-beta.2",
10
+ "@aiot-toolkit/debugger": "1.1.1-aspect-beta.2",
11
+ "@aiot-toolkit/dsl-vue": "1.1.1-aspect-beta.2",
12
+ "@aiot-toolkit/dsl-xvm": "1.1.1-aspect-beta.2",
13
+ "@aiot-toolkit/packager": "1.1.1-aspect-beta.2",
14
+ "@aiot-toolkit/server": "1.1.1-aspect-beta.2",
15
+ "@aiot-toolkit/shared-utils": "1.1.1-aspect-beta.2",
16
16
  "@babel/core": "^7.9.6",
17
17
  "@babel/plugin-syntax-jsx": "^7.8.3",
18
18
  "@babel/preset-env": "^7.9.6",
@@ -52,5 +52,5 @@
52
52
  "supertest": "^3.3.0",
53
53
  "webpack-cli": "^4.3.0"
54
54
  },
55
- "gitHead": "86f3819e1955fabb17c0c3834e20648f8a96b780"
55
+ "gitHead": "4be7e5e770c9e17b64ac8b39cf656991c20ad922"
56
56
  }