monaca-lib
Advanced tools
Comparing version 4.1.10 to 5.0.0
224
CHANGELOG.md
CHANGELOG | ||
==== | ||
v5.0.0 | ||
---- | ||
# Features | ||
* Support Capacitor Projects (Beta) | ||
* Support Yarn Projects (Beta) | ||
# Breaking changes | ||
* Modified `isMonacaProject` function. The project is "Monaca" if it is either "Cordova" or "Capacitor" project. | ||
* Removed `_getNpmPathForSpawn` method. | ||
* Removed `_getGlobalNpmPath` method. | ||
# Deprecated | ||
* Removed `includeInExplicitFilterList`. | ||
* Removed `_fileFilter`. | ||
* Removed `_excludeFromCloudDelete`. | ||
v4.1.10 | ||
@@ -17,2 +38,3 @@ ---- | ||
---- | ||
* Added retry to `downloadFile` | ||
@@ -22,2 +44,3 @@ | ||
---- | ||
* Pinned latest blank template for Cordova 12 | ||
@@ -27,2 +50,3 @@ | ||
---- | ||
* Support iOS Simulator build | ||
@@ -32,2 +56,3 @@ | ||
---- | ||
* Cordova 11 support | ||
@@ -37,3 +62,4 @@ | ||
---- | ||
* Remove NPM API-related functions | ||
* Remove NPM API-related functions | ||
* Remove internal function `_npmInit` | ||
@@ -43,2 +69,3 @@ | ||
---- | ||
* Update new Monaca Document Url. | ||
@@ -48,2 +75,3 @@ | ||
---- | ||
* Fix to return the error message got from the server. | ||
@@ -53,2 +81,3 @@ | ||
---- | ||
* Upload missing project creation template to NPM | ||
@@ -58,2 +87,3 @@ | ||
---- | ||
* Return `isTranspilable` to `project` instance in Monaca Localkit | ||
@@ -63,2 +93,3 @@ | ||
---- | ||
* Fix `cloneProject` function when project name contains Japanese characters | ||
@@ -69,2 +100,3 @@ * Change default cordova version from 9.0.0 to 10.0.0 | ||
---- | ||
* Fix `monaca download` | ||
@@ -74,2 +106,3 @@ | ||
---- | ||
* Accept `filenamecallback` function as Promise function | ||
@@ -80,2 +113,3 @@ * Synchronize version with other Monaca Development Kits | ||
---- | ||
* Update dependencies to resolve circular dependency warnings | ||
@@ -85,2 +119,3 @@ | ||
---- | ||
* Update Cordova 10 Blank Template for Project Migration Command | ||
@@ -90,2 +125,3 @@ | ||
---- | ||
* Fixed Resource Permission for Localkit on Non-Windows | ||
@@ -95,2 +131,3 @@ | ||
---- | ||
* Upgrade default blank template to the latest version | ||
@@ -101,2 +138,3 @@ * Update default cordova version to 9.0.0 | ||
---- | ||
* Fixes to support older version of Nodejs (CERT_HAS_EXPIRED). | ||
@@ -107,2 +145,3 @@ * We will drop support of Node 8.x in the future. Please upgrade Node to 10.x or higher. | ||
---- | ||
* Fixed to encode the file path param for file comparison operation | ||
@@ -112,2 +151,3 @@ | ||
---- | ||
* Fixed to encode the file path param for upload operation | ||
@@ -117,2 +157,3 @@ | ||
---- | ||
* Validated application icon for electron build | ||
@@ -122,2 +163,3 @@ | ||
---- | ||
* Validated cordova version for electron build | ||
@@ -127,2 +169,3 @@ | ||
---- | ||
* Fixed inspector run in Android 9 | ||
@@ -134,2 +177,3 @@ * Fixed remove non-empoty directories | ||
---- | ||
* Fixed to encode the file path param | ||
@@ -139,2 +183,3 @@ | ||
---- | ||
* Modified `checkModifiedFiles` function to show spinner and file information when reading file for upload/download process if `showSpinner` flag is passed. | ||
@@ -144,2 +189,3 @@ | ||
---- | ||
* Added new properties - `npmPath` and `nodePath` to the `Monaca` Object. These properties are used to `spawn` the `npm` process. | ||
@@ -150,2 +196,3 @@ * Fixed for `Monaca Localkit@3.1.0` - use spawned `npm` process to install `dependencies` instead of `npm` API. | ||
---- | ||
* Minor fix to the comment blocks. | ||
@@ -155,2 +202,3 @@ | ||
---- | ||
* Added `getRemoteProjectFiles` for reading project files from cloud. | ||
@@ -164,2 +212,3 @@ * Added `getRemoteProjectFilesByPath` to read project files from cloud specified by file path. | ||
---- | ||
* Fixed backup process of package.json for `monaca update` and `monaca init`. | ||
@@ -171,2 +220,3 @@ | ||
#### Features | ||
* Added `upgrade` function. This function is used to upgrade projects created using Monaca Lib 2.x to Monaca Lib 3. | ||
@@ -189,2 +239,3 @@ * Added `init` function. This function is used to initialize projects created using other CLI tools to the Monaca structure. | ||
#### Deprecated | ||
* Removed `isTranspilable`. | ||
@@ -197,2 +248,3 @@ * Removed `isTranspileEnabled`. | ||
#### Breaking changes | ||
* Added `dev` to `_npmInstall` function to be able to install dev depependencies. | ||
@@ -212,2 +264,3 @@ * Modified `initComponents`function to get Monaca Components from `blank` template. | ||
---- | ||
* Fixed bug in `uploadProject` and `downloadProject` function. | ||
@@ -217,2 +270,3 @@ | ||
---- | ||
* Added `checkForMinimumRequirements` to the `buildParams` parameter in the `checkBuildAvailability` method. | ||
@@ -222,2 +276,3 @@ | ||
---- | ||
* appended `path` to the `upload` and `download` request url | ||
@@ -229,7 +284,8 @@ * return `upload` and `download` progress to `localkit` | ||
---- | ||
* added `loader.js` and `loader.css` to webpack-dev-server (webpack.dev.config.js) | ||
v2.7.9 | ||
---- | ||
* add optional param to `cloneProject` function (to fix `monaca import`) | ||
@@ -241,2 +297,3 @@ * change content of default `.monacaignore` | ||
---- | ||
* Modified `webpack` development configuration of `Angular` to fix `live reloading` | ||
@@ -246,2 +303,3 @@ | ||
---- | ||
* Modified `webpack` development configuration to generate files to `www` directory | ||
@@ -251,2 +309,3 @@ | ||
---- | ||
* Improved `getLocalProjectFiles` functions by filtering files before further processing | ||
@@ -258,2 +317,3 @@ * Generated only one `.monacaignore` file for all project templates | ||
---- | ||
* Added `historyApiFallback` to angular template | ||
@@ -268,2 +328,3 @@ * Modified `checkModifiedFiles` functions to return file differences if `options.actionType` is passed as `downloadProject` | ||
---- | ||
* Added directory path validation check for signing APIs. | ||
@@ -274,2 +335,3 @@ * Added fetching signing certificate collection API. | ||
---- | ||
* monaca: Stop live relaod in case of transpile project. | ||
@@ -279,2 +341,3 @@ | ||
---- | ||
* Reverted changes to the client request creation for CLI. | ||
@@ -284,2 +347,3 @@ | ||
---- | ||
* Added Android and iOS Signing APIs | ||
@@ -289,2 +353,3 @@ | ||
---- | ||
* monaca: Added React-Native Project Support | ||
@@ -295,2 +360,3 @@ * monaca: Updated iOS Webkit Debug Proxy | ||
---- | ||
* monaca: fixed npm issue for CLI. | ||
@@ -301,2 +367,3 @@ * monaca: improved error message when a remote build fails. | ||
---- | ||
* monaca: internal logic fix. | ||
@@ -307,2 +374,3 @@ * templates: Fixed default webpack configurations for Angular 2+ in order to support PostCSS correctly. | ||
---- | ||
* monaca: Improved `startRemoteBuild` method logic. | ||
@@ -312,2 +380,3 @@ | ||
---- | ||
* monaca: Added remote build history API. | ||
@@ -318,2 +387,3 @@ * monaca: Improved logout method. | ||
---- | ||
* templates: Added support to Cordova 6.5 templates. | ||
@@ -325,2 +395,3 @@ * monaca: Allowed `.bower.json` sync to Cloud. | ||
---- | ||
* monaca: Updated Webpack resolvers for transpilable templates. | ||
@@ -330,2 +401,3 @@ | ||
---- | ||
* monaca: Updated `vue-template-compile` to fix issue with Vue templates. | ||
@@ -335,2 +407,3 @@ | ||
---- | ||
* monaca: Added support to the latest Vue and React templates with Onsen 2.4.0. | ||
@@ -342,2 +415,3 @@ * templates: Fixed dependencies and debugging avilability. | ||
---- | ||
* monaca: Fixed local debugging issue. | ||
@@ -347,2 +421,3 @@ | ||
---- | ||
* monaca: Fixed critical sync bug when the project path contains special characters. | ||
@@ -352,2 +427,3 @@ | ||
---- | ||
* monaca: Fixed isTranspileEnabled check. | ||
@@ -357,2 +433,3 @@ | ||
---- | ||
* templates: fixed Vue Webpack configuration. | ||
@@ -365,2 +442,3 @@ * monaca: Added API endpoint management. | ||
---- | ||
* templates: Added missing additionalDependencies. | ||
@@ -370,2 +448,3 @@ | ||
---- | ||
* templates: Added Vue.js 2.0 templates for Onsen UI 2.2.0. | ||
@@ -376,2 +455,3 @@ * templates: Updated ReactJS and Angular 2+ templates for Onsen UI 2.2.0. | ||
---- | ||
* monaca: Added deleteProjectId functionality. | ||
@@ -382,2 +462,3 @@ * monaca: Fixed checkModifiedFiles error handler. | ||
---- | ||
* monaca: Fixed Cordova Project check. | ||
@@ -389,2 +470,3 @@ * monaca: Fixed iOS build availability check. | ||
---- | ||
* templates: Use autoprefixer for all the CSS. | ||
@@ -396,2 +478,3 @@ * templates: Conservative minify for Angular 2. | ||
---- | ||
* monaca: Improve error message. | ||
@@ -401,2 +484,3 @@ | ||
---- | ||
* templates: Renamed index.ejs => index.html.ejs | ||
@@ -409,2 +493,3 @@ * templates: HTML minifier is case sensitive now. Fixes Angular2 directive naming issues. | ||
---- | ||
* monaca: Added patched minimatch dependency. | ||
@@ -414,2 +499,3 @@ | ||
---- | ||
* monaca: Added CI support. | ||
@@ -419,2 +505,3 @@ | ||
---- | ||
* monaca: Update 'portfinder' dependency. | ||
@@ -425,2 +512,3 @@ * monaca: Fixed escape character bug on project path. | ||
---- | ||
* monaca: Reduce package size. | ||
@@ -431,2 +519,3 @@ * monaca: Improve Webpack output in development mode. | ||
---- | ||
* monaca: Minor improvement to transpiler configuration. | ||
@@ -436,2 +525,3 @@ | ||
---- | ||
* monaca: Localkit support when running transpiler. | ||
@@ -441,2 +531,3 @@ | ||
---- | ||
* monaca and localkit: Various fixes. | ||
@@ -447,2 +538,3 @@ * monaca: Webpack dev server support. | ||
---- | ||
* monaca: Allowed upload/download for config files inside the root directory. | ||
@@ -452,2 +544,3 @@ | ||
---- | ||
* monaca: Fixed wrong files deletion in `downloadProject()`. | ||
@@ -457,2 +550,3 @@ | ||
---- | ||
* monaca: Added missing `options` to `downloadProject` method in `Monaca.startRemoteBuild` API. | ||
@@ -462,111 +556,131 @@ | ||
---- | ||
* monaca: Fixed .monaca/project_info.json not updated when syncing back from the Cloud. | ||
* monaca: Fixed to delete unnecessary files after the build process. | ||
* monaca: Fixed .monaca/project_info.json not updated when syncing back from the Cloud. | ||
* monaca: Fixed to delete unnecessary files after the build process. | ||
v1.1.9 | ||
---- | ||
* monaca: Fixed `Monaca.startRemoteBuild()` API to support placeholders. | ||
* monaca: Fixed `Monaca.startRemoteBuild()` API to support placeholders. | ||
v1.1.8 | ||
---- | ||
* localkit: Added Cordova Version when getting project list. | ||
* localkit: Added a filter to the files when getting project file tree. | ||
* monaca: Added `showUrl` argument to `Monaca.buildProject()` API. | ||
* localkit: Added Cordova Version when getting project list. | ||
* localkit: Added a filter to the files when getting project file tree. | ||
* monaca: Added `showUrl` argument to `Monaca.buildProject()` API. | ||
v1.1.7 | ||
---- | ||
* monaca: Added `delete` argument to `uploadFiles` method. | ||
* monaca: Added `delete` argument to `uploadFiles` method. | ||
v1.1.6 | ||
---- | ||
* monaca: Added `Monaca.getLatestVersionInfo()` API to get the latest version information. | ||
* monaca: Support for .monacaignore so that the user can specify what file to ignore when upload/download from the Cloud. | ||
* monaca: Added support for `--dry-run` and `--delete` when upload/downloading from the Cloud. | ||
* monaca: Changed to unzip2 npm module for unzipping the archive. | ||
* monaca: Added `Monaca.getLatestVersionInfo()` API to get the latest version information. | ||
* monaca: Support for .monacaignore so that the user can specify what file to ignore when upload/download from the Cloud. | ||
* monaca: Added support for `--dry-run` and `--delete` when upload/downloading from the Cloud. | ||
* monaca: Changed to unzip2 npm module for unzipping the archive. | ||
v1.1.5 | ||
---- | ||
* monaca: Fixed `Monaca.uploadFile()` API to limit the number of concurrent connections. | ||
* monaca: Removed `Monaca.buildProject()` API timeout. | ||
* monaca: Fixed `Monaca.uploadFile()` API to limit the number of concurrent connections. | ||
* monaca: Removed `Monaca.buildProject()` API timeout. | ||
v1.1.5-rc.3 | ||
---- | ||
* monaca: Fixed `Monaca.uploadFile()` API to upload using Base64 encoding to avoid data corruption. | ||
* monaca: Fixed `Monaca.uploadFile()` API to upload using Base64 encoding to avoid data corruption. | ||
v1.1.5-rc.2 | ||
---- | ||
* monaca: Fixed `Monaca.uploadProject()` API to also upload platform specific files. | ||
* localkit: Fixed nic address does not return a valid value in some cases. | ||
* monaca: Fixed `Monaca.uploadProject()` API to also upload platform specific files. | ||
* localkit: Fixed nic address does not return a valid value in some cases. | ||
v1.1.5-rc.1 | ||
---- | ||
* monaca: Added `Monaca.getCurrentUser()` API. | ||
* localkit: Added `Localkit.generateOneTimePassword()`, `Localkit.validateOneTimePassword()`, `Localkit.generateLocalPairingKey()` API. | ||
* monaca: Fixed the POST parameter not sent to the server for some reason. | ||
* monaca: Added `Monaca.getCurrentUser()` API. | ||
* localkit: Added `Localkit.generateOneTimePassword()`, `Localkit.validateOneTimePassword()`, `Localkit.generateLocalPairingKey()` API. | ||
* monaca: Fixed the POST parameter not sent to the server for some reason. | ||
v1.1.4 | ||
---- | ||
* monaca: Fix the number of concurrent connections during the network requests. | ||
* monaca: Fix the number of concurrent connections during the network requests. | ||
v1.1.3 | ||
---- | ||
* monaca: Fix issue in `Monaca.cloneProject()` where promise was never resolved. | ||
* monaca: Fix issue in `Monaca.cloneProject()` where promise was never resolved. | ||
v1.1.0-rc.10 | ||
---- | ||
* Released without any changes. | ||
* Released without any changes. | ||
v1.1.0-rc.9 | ||
---- | ||
* localkit: Return `frameworkVersion` when calling `Localkit.getProject()` function. | ||
* localkit: Now `Localkit` emits `live-reload` event when the file has changed. | ||
* localkit: Return `frameworkVersion` when calling `Localkit.getProject()` function. | ||
* localkit: Now `Localkit` emits `live-reload` event when the file has changed. | ||
v1.1.0-rc.8 | ||
---- | ||
* localkit: Fixed bug when serving multiple projects. | ||
* localkit: Fixed bug when serving multiple projects. | ||
v1.1.0-rc.7 | ||
---- | ||
* monaca: Added `isBuildOnly` parameter to `Monaca.createProject()` API. | ||
* monaca: Rewrote `Monaca.getTemplates()` method to get templates from Monaca Cloud. | ||
* monaca: Added `Monaca.createFromTemplate()` method to create a project from a template in Monaca cloud. | ||
* monaca: Added `disableStatusUpdate` parameter to `Monaca.getLatestNews()`. | ||
* localkit: Added `Localkit.startWatchProject()`, `Localkit.stopWatchingProject()` and `Localkit.isWatchingProject()` for more granular control. | ||
* monaca: Added `options.language` parameter. | ||
* monaca: Added `options` object to `Monaca.relogin()`. Works exactly like the parameters for `Monaca.login()`. | ||
* localkit: Added `Localkit.initInspector()` method. | ||
* localkit: Fixed `Localkit.startWatch()` so it will always be resolved. | ||
* monaca: Return whole response body in `Monaca.login` instead of just the message. | ||
* monaca: Added `Monaca.download()` method. | ||
* localkit: Removed nw.js dependency. | ||
* localkit: `Localkit` object is now an event emitter. | ||
* localkit: Fixed `Localkit.stopHttpServer` so it will work even if clients are connected to SSE. | ||
* localkit: Kill adb processes on shutdown. | ||
* localkit: Add ability to override config.xml project name in `Localkit.addProject()` and `Localkit.setProjects()`. | ||
* monaca: Don't save cloud project id in `Monaca.cloneProject()`. | ||
* monaca: Return whole JSON response when making requests to Monaca Cloud. | ||
* monaca: Added `isBuildOnly` parameter to `Monaca.createProject()` API. | ||
* monaca: Rewrote `Monaca.getTemplates()` method to get templates from Monaca Cloud. | ||
* monaca: Added `Monaca.createFromTemplate()` method to create a project from a template in Monaca cloud. | ||
* monaca: Added `disableStatusUpdate` parameter to `Monaca.getLatestNews()`. | ||
* localkit: Added `Localkit.startWatchProject()`, `Localkit.stopWatchingProject()` and `Localkit.isWatchingProject()` for more granular control. | ||
* monaca: Added `options.language` parameter. | ||
* monaca: Added `options` object to `Monaca.relogin()`. Works exactly like the parameters for `Monaca.login()`. | ||
* localkit: Added `Localkit.initInspector()` method. | ||
* localkit: Fixed `Localkit.startWatch()` so it will always be resolved. | ||
* monaca: Return whole response body in `Monaca.login` instead of just the message. | ||
* monaca: Added `Monaca.download()` method. | ||
* localkit: Removed nw.js dependency. | ||
* localkit: `Localkit` object is now an event emitter. | ||
* localkit: Fixed `Localkit.stopHttpServer` so it will work even if clients are connected to SSE. | ||
* localkit: Kill adb processes on shutdown. | ||
* localkit: Add ability to override config.xml project name in `Localkit.addProject()` and `Localkit.setProjects()`. | ||
* monaca: Don't save cloud project id in `Monaca.cloneProject()`. | ||
* monaca: Return whole JSON response when making requests to Monaca Cloud. | ||
v1.0.4 | ||
---- | ||
* monaca: Added `Monaca.getLatestNews()` to fetch latest news and status on known issues from Monaca Cloud. | ||
* localkit: Added `options.clientId` to `Localkit.startProject()` method. Used to start a project on one device instead of sending the start signal to all connected devices. | ||
* localkit: Added `Localkit.startInspector()` to start an inspector when the computer is connected to Localkit. | ||
* monoaca: Added `Monaca.isMonacaProject()` to check if a directory is a Monaca project. | ||
* monaca: Added `Monaca.getLatestNews()` to fetch latest news and status on known issues from Monaca Cloud. | ||
* localkit: Added `options.clientId` to `Localkit.startProject()` method. Used to start a project on one device instead of sending the start signal to all connected devices. | ||
* localkit: Added `Localkit.startInspector()` to start an inspector when the computer is connected to Localkit. | ||
* monoaca: Added `Monaca.isMonacaProject()` to check if a directory is a Monaca project. | ||
v1.0.3 | ||
---- | ||
* monaca: Added `options` parameter to `Monaca.login()` to specify version. | ||
* monaca: Added `Monaca.isCordovaProject()` to check if a directory is a Cordova project. | ||
* monaca: Added `options` parameter to `Monaca.login()` to specify version. | ||
* monaca: Added `Monaca.isCordovaProject()` to check if a directory is a Cordova project. | ||
v1.0.2 | ||
---- | ||
* monaca: Fixed bug where .cordova directory was not created correctly when missing. | ||
* monaca: Fixed bug where .cordova directory was not created correctly when missing. | ||
v1.0.1 | ||
---- | ||
* monaca: Added configuration methods. | ||
* monaca: Added proxy support. | ||
* monaca: Added configuration methods. | ||
* monaca: Added proxy support. | ||
v1.0.0 | ||
------ | ||
* Initial version. | ||
* Initial version. |
{ | ||
"name": "monaca-lib", | ||
"version": "4.1.10", | ||
"version": "5.0.0", | ||
"description": "Monaca cloud and localkit API bindings for JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "./src/main.js", |
@@ -899,2 +899,7 @@ (function() { | ||
} | ||
if (utils.isCapacitorProject(project_path)) { | ||
// capacitor project should not be added to projects for debugger. | ||
deferred.resolve(null); | ||
return; | ||
} | ||
@@ -917,3 +922,2 @@ project.name = _project.name || project.name; | ||
} | ||
deferred.resolve(project); | ||
@@ -931,3 +935,5 @@ }, | ||
return Q.all(promises); | ||
return Q.all(promises).then((projects)=>{ | ||
return projects.filter((project) => project != null); | ||
}); | ||
}; | ||
@@ -934,0 +940,0 @@ |
@@ -7,2 +7,3 @@ const path = require('path'); | ||
let gMonaca; | ||
let gIsCapacitorProject = null; | ||
@@ -245,2 +246,10 @@ const packageBackupJsonFile = 'package.backup.json'; | ||
const isCapacitorProject = (projectDir) => { | ||
if (gIsCapacitorProject !== null) { | ||
return gIsCapacitorProject; | ||
} | ||
gIsCapacitorProject = utils.isCapacitorProject(projectDir); | ||
return gIsCapacitorProject; | ||
}; | ||
/** | ||
@@ -255,4 +264,7 @@ * | ||
const installLatestCordova = (projectDir, monaca) => { | ||
utils.info(`[Cordova] Installing Cordova ${utils.CORDOVA_VERSION}...`); | ||
return new Promise((resolve, reject) => { | ||
if (isCapacitorProject(projectDir)) return resolve(projectDir); | ||
utils.info(`[Cordova] Installing Cordova ${utils.CORDOVA_VERSION}...`); | ||
let installDependencies = []; | ||
@@ -376,5 +388,8 @@ | ||
const projectInfo = path.resolve(projectDir, '.monaca', 'project_info.json'); | ||
const projectInfoTemplate = path.resolve(__dirname, 'template', 'blank', '.monaca', 'project_info.json'); | ||
let projectInfoTemplate = path.resolve(__dirname, 'template', 'blank', '.monaca', 'project_info.json'); | ||
utils.info('[.monaca] Creating project_info.json...'); | ||
if (isCapacitorProject(projectDir)) { | ||
projectInfoTemplate = path.resolve(__dirname, 'template', 'capacitor-basic', '.monaca', 'project_info.json'); | ||
} | ||
return new Promise((resolve, reject) => { | ||
@@ -398,6 +413,10 @@ fs.copy(projectInfoTemplate, projectInfo, (err) => { | ||
initIconsSplashes: function (projectDir) { | ||
utils.info('[res] Inserting icons and splashes...'); | ||
return new Promise((resolve, reject) => { | ||
const resFolder = path.join(projectDir, 'res'); | ||
const resTemplateFolder = path.resolve(__dirname, 'template', 'blank', 'res'); | ||
utils.info('[res] Inserting icons and splashes...'); | ||
let resFolder = path.join(projectDir, 'res'); | ||
let resTemplateFolder = path.resolve(__dirname, 'template', 'blank', 'res'); | ||
if (isCapacitorProject(projectDir)) { | ||
resTemplateFolder = path.resolve(__dirname, 'template', 'capacitor-basic', 'assets'); | ||
resFolder = path.join(projectDir, 'assets'); | ||
} | ||
@@ -420,7 +439,11 @@ copyDirectory(resTemplateFolder, resFolder) | ||
initComponents: function (projectDir) { | ||
utils.info('[www] Inserting components...'); | ||
return new Promise((resolve, reject) => { | ||
const componentsFolder = path.join(projectDir, 'www', 'components'); | ||
const componentsTemplateFolder = path.resolve(__dirname, 'template', 'blank', 'www', 'components'); | ||
if (isCapacitorProject(projectDir)) { | ||
// Skip adding components for capacitor projects | ||
return resolve(projectDir) | ||
} | ||
utils.info('[www] Inserting components...'); | ||
copyDirectory(componentsTemplateFolder, componentsFolder) | ||
@@ -442,4 +465,6 @@ .then(() => resolve(projectDir)) | ||
createConfigFile: function (projectDir) { | ||
utils.info('[config.xml] Creating file...'); | ||
return new Promise((resolve, reject) => { | ||
if (isCapacitorProject(projectDir)) return resolve(projectDir); | ||
utils.info('[config.xml] Creating file...'); | ||
const configFolder = path.resolve(projectDir, 'config.xml'); | ||
@@ -468,3 +493,6 @@ const configTemplateFolder = path.resolve(__dirname, 'template', 'blank', 'config.xml'); | ||
const packageFolder = path.resolve(projectDir, 'package.json'); | ||
const packageTemplateFolder = path.resolve(__dirname, 'template', 'blank', 'package.json'); | ||
let packageTemplateFolder = path.resolve(__dirname, 'template', 'blank', 'package.json'); | ||
if (isCapacitorProject(projectDir)) { | ||
packageTemplateFolder = path.resolve(__dirname, 'template', 'capacitor-basic', 'package.json'); | ||
} | ||
@@ -471,0 +499,0 @@ if (fs.existsSync(packageFolder)) { |
122
src/utils.js
@@ -39,13 +39,2 @@ | ||
/** | ||
* @todo | ||
* @deprecated in the next major release | ||
*/ | ||
let includeInExplicitFilterList = function(f) { | ||
if ( f.indexOf('/.monaca') >= 0 || f.indexOf('/node_modules') >= 0 || f.indexOf('/.git') >= 0 ) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
let info = function(msg, deferred, spinner) { | ||
@@ -128,2 +117,91 @@ if (deferred) deferred.notify(msg); | ||
/** | ||
* @method | ||
* @description | ||
* isCapacitorProject | ||
* | ||
* @param {String} projectDir Project directory | ||
* @return {String} | ||
*/ | ||
const isCapacitorProject = (projectDir) => { | ||
try { | ||
const projectConfig = require(path.join(projectDir, 'package.json')); | ||
if (projectConfig && projectConfig.dependencies && projectConfig.dependencies['@capacitor/core']) { | ||
return true; | ||
} | ||
} catch (err) {} | ||
return false; | ||
}; | ||
/** | ||
* Checks if a project is using Yarn as its package manager. | ||
* | ||
* @param {string} projectDir - The directory path of the project. | ||
* @returns {boolean} - Returns true if the project uses Yarn, false otherwise. | ||
*/ | ||
const isUsingYarn = (projectDir) => { | ||
try { | ||
const projectConfig = require(path.join(projectDir, 'package.json')); | ||
const monacaPreviewScript = projectConfig.scripts && projectConfig.scripts['monaca:preview']; | ||
if (monacaPreviewScript && monacaPreviewScript.indexOf('yarn') >= 0) { | ||
return true; | ||
} | ||
} catch (err) { | ||
info(err); | ||
} | ||
return false; | ||
}; | ||
/** | ||
* @method | ||
* @description | ||
* return an executable global npm path. | ||
* @return {String} | ||
*/ | ||
const getPackageManager = function (projectDir) { | ||
let command = 'npm'; | ||
if (isUsingYarn(projectDir)) { | ||
command = 'yarn'; | ||
} | ||
if (process.platform !== 'win32') return command; | ||
return command + '.cmd'; | ||
} | ||
const checkIfPackageManagerExists = function (npm, packageManager, emitter, exitCb) { | ||
if (!npm || !npm.pid) { | ||
let message = ''; | ||
if (packageManager.indexOf('yarn') >= 0) { | ||
message = 'YARN_NOT_FOUND'; | ||
} else { | ||
message = 'NPM_NOT_FOUND'; | ||
} | ||
info(`>>> Could not spawn ${packageManager}. Please install/configure ${packageManager}.\n\r`); | ||
if (packageManager.indexOf('yarn') >= 0) { | ||
emitter.emit('output', { type: 'error', message: message }); | ||
} | ||
exitCb(1); | ||
} | ||
}; | ||
const relayErrorMessage = function (emitter, errorMessage) { | ||
if (!errorMessage) return; | ||
// 1. display to console | ||
info(errorMessage); | ||
// 2. display to emitter for localkit | ||
if ( | ||
errorMessage.indexOf('npm: command not found') >= 0 || | ||
errorMessage.indexOf('node: No such file or directory') >= 0 || | ||
errorMessage.indexOf('\'node\' is not recognized as an internal or external command') >= 0 | ||
) { | ||
emitter.emit('output', { type: 'error', message: 'NPM_NOT_FOUND' }); | ||
} else if ( | ||
errorMessage.indexOf('Corepack must currently be enabled by running corepack enable in your terminal.') >= 0 | ||
) { | ||
emitter.emit('output', { type: 'error', message: 'YARN_COREPACK_IS_DISABLE' }); | ||
} else { | ||
emitter.emit('output', { type: 'progress', message: errorMessage }); | ||
} | ||
}; | ||
let sleep = (ms) => { | ||
@@ -166,9 +244,9 @@ return new Promise(resolve => setTimeout(resolve, ms)); | ||
module.exports = { | ||
filterIgnoreFiles: filterIgnoreFiles, | ||
isDirectory: isDirectory, | ||
includeInExplicitFilterList: includeInExplicitFilterList, | ||
info: info, | ||
filterObjectByKeys: filterObjectByKeys, | ||
filter: filter, | ||
needToInstallCordova: needToInstallCordova, | ||
isCapacitorProject, | ||
filterIgnoreFiles, | ||
isDirectory, | ||
info, | ||
filterObjectByKeys, | ||
filter, | ||
needToInstallCordova, | ||
MIGRATION_FOLDER, | ||
@@ -178,7 +256,11 @@ MIGRATION_TEMPLATES_FOLDER, | ||
CORDOVA_VERSION, | ||
readJSONFile: readJSONFile, | ||
isEmptyObject: isEmptyObject, | ||
readJSONFile, | ||
isEmptyObject, | ||
spinnerFail, | ||
spinnerLoading, | ||
spinnerSuccess, | ||
isUsingYarn, | ||
getPackageManager, | ||
checkIfPackageManagerExists, | ||
relayErrorMessage, | ||
startSpinner, | ||
@@ -185,0 +267,0 @@ sleep, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found
Found 1 instance in 1 package
19808770
152
27300
86
7