@appsemble/cli
Advanced tools
Comparing version 0.0.2 to 0.1.0
@@ -0,4 +1,9 @@ | ||
const path = require('path'); | ||
const fs = require('fs-extra'); | ||
const log = require('winston'); | ||
const CLIError = require('./CLIError'); | ||
const explorer = require('./explorer'); | ||
const idFromPackageName = require('./idFromPackageName'); | ||
@@ -9,3 +14,3 @@ | ||
* | ||
* @param {string} path - The project root to load the configuration from. | ||
* @param {string} projectPath - The project root to load the configuration from. | ||
* | ||
@@ -15,6 +20,25 @@ * @returns {Object} The resulting configuration. | ||
module.exports = async function loadConfig(projectPath) { | ||
const { config, filepath } = await explorer.load(projectPath); | ||
const data = await explorer.load(projectPath); | ||
if (data == null) { | ||
throw new CLIError('Appsemble configuration file not found'); | ||
} | ||
const { | ||
config, | ||
filepath, | ||
} = data; | ||
log.info('Using configuration file:', filepath); | ||
log.debug('configuration:', config); | ||
return config; | ||
const pkgPath = path.resolve(filepath, '..', 'package.json'); | ||
if (!fs.existsSync(pkgPath)) { | ||
return config; | ||
} | ||
const pkg = await fs.readJson(pkgPath); | ||
if (!pkg.private) { | ||
log.warn('It is recommended to set "private" to true in package.json to prevent accidental publishing to npm.'); | ||
} | ||
return { | ||
id: idFromPackageName(pkg.name), | ||
description: pkg.description, | ||
version: pkg.version, | ||
...config, | ||
}; | ||
}; |
@@ -1,5 +0,11 @@ | ||
const request = require('request-promise-native'); | ||
const { | ||
promisify, | ||
} = require('util'); | ||
const request = promisify(require('request')); | ||
const log = require('winston'); | ||
const CLIError = require('./CLIError'); | ||
let baseUrl; | ||
@@ -25,3 +31,9 @@ | ||
const response = await request(options); | ||
return JSON.parse(response); | ||
if (response.statusCode >= 500) { | ||
throw new Error(response); | ||
} | ||
if (response.statusCode >= 400) { | ||
throw new CLIError(JSON.parse(response.body).reason); | ||
} | ||
return JSON.parse(response.body); | ||
} | ||
@@ -28,0 +40,0 @@ |
{ | ||
"name": "@appsemble/cli", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "A CLI for the Appsemble extension platform", | ||
@@ -12,3 +12,3 @@ "homepage": "https://www.appsemble.com", | ||
"bin": { | ||
"appsemble": "./lib/cli/cli.js" | ||
"appsemble": "./lib/cli.js" | ||
}, | ||
@@ -22,5 +22,4 @@ "dependencies": { | ||
"request": "^2.83.0", | ||
"request-promise-native": "^1.0.5", | ||
"winston": "^2.4.0", | ||
"yargs": "^10.1.2" | ||
"yargs": "^11.0.0" | ||
}, | ||
@@ -27,0 +26,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
11291
8
16
315
1
38
4
1
+ Addedcross-spawn@6.0.5(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedexeca@1.0.0(transitive)
+ Addedget-stream@4.1.0(transitive)
+ Addedinvert-kv@2.0.0(transitive)
+ Addedlcid@2.0.0(transitive)
+ Addedmap-age-cleaner@0.1.3(transitive)
+ Addedmem@4.3.0(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addednice-try@1.0.5(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedos-locale@3.1.0(transitive)
+ Addedp-defer@1.0.0(transitive)
+ Addedp-is-promise@2.1.0(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedyargs@11.1.1(transitive)
+ Addedyargs-parser@9.0.2(transitive)
- Removedrequest-promise-native@^1.0.5
- Removedcross-spawn@5.1.0(transitive)
- Removedexeca@0.7.0(transitive)
- Removedget-stream@3.0.0(transitive)
- Removedinvert-kv@1.0.0(transitive)
- Removedlcid@1.0.0(transitive)
- Removedlru-cache@4.1.5(transitive)
- Removedmem@1.1.0(transitive)
- Removedmimic-fn@1.2.0(transitive)
- Removedos-locale@2.1.0(transitive)
- Removedpseudomap@1.0.2(transitive)
- Removedrequest-promise-core@1.1.4(transitive)
- Removedrequest-promise-native@1.0.9(transitive)
- Removedstealthy-require@1.1.1(transitive)
- Removedyallist@2.1.2(transitive)
- Removedyargs@10.1.2(transitive)
- Removedyargs-parser@8.1.0(transitive)
Updatedyargs@^11.0.0