@rocketmakers/nebula-platform
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -7,2 +7,3 @@ "use strict"; | ||
const fs_1 = require("@rocketmakers/shell-commands/lib/fs"); | ||
const js_yaml_1 = require("js-yaml"); | ||
const path_1 = require("path"); | ||
@@ -39,24 +40,44 @@ const PlatformConfig_1 = require("../../core/PlatformConfig"); | ||
// Config | ||
const configPath = parsedFlags.config || path_1.join(process.cwd(), 'nebula.json'); | ||
if (!fs_1.FileSystem.exists(configPath)) { | ||
const configPaths = parsedFlags.config | ||
? [parsedFlags.config] | ||
: [path_1.join(process.cwd(), 'nebula.json'), path_1.join(process.cwd(), 'nebula.yaml')]; | ||
let foundConfigPath; | ||
for (const configPath of configPaths) { | ||
if (fs_1.FileSystem.exists(configPath)) { | ||
foundConfigPath = configPath; | ||
break; | ||
} | ||
} | ||
if (!foundConfigPath) { | ||
// TODO: add Nebula init if config file does not exist | ||
nebula_core_1.errorAndExit(1, `> Unable to find Nebula config file: ${configPath}`); | ||
nebula_core_1.errorAndExit(1, `> Unable to find Nebula config file: ${foundConfigPath}`); | ||
return; | ||
} | ||
const rawConfig = (await fs_1.FileSystem.readFileAsync(configPath, { encoding: 'utf-8' })).toString(); | ||
const rawConfig = (await fs_1.FileSystem.readFileAsync(foundConfigPath, { encoding: 'utf-8' })).toString(); | ||
let validatedConfig; | ||
let parsedConfig; | ||
try { | ||
const config = new PlatformConfig_1.PlatformConfig({ ...JSON.parse(rawConfig), basePath: path_1.dirname(configPath) }); | ||
nebula_core_1.trace('Platform module config validation...'); | ||
validatedConfig = await config.validate(); | ||
nebula_core_1.trace(JSON.stringify(validatedConfig)); | ||
parsedConfig = JSON.parse(rawConfig); | ||
} | ||
catch (err) { | ||
nebula_core_1.trace(`Config validation failed`); | ||
if (typeof err === 'object' && (err === null || err === void 0 ? void 0 : err.name) === 'SyntaxError') { | ||
nebula_core_1.error(`Config is not valid JSON`); | ||
try { | ||
parsedConfig = await js_yaml_1.safeLoad(rawConfig); | ||
} | ||
catch { } | ||
} | ||
try { | ||
if (parsedConfig) { | ||
const config = new PlatformConfig_1.PlatformConfig({ ...parsedConfig, basePath: path_1.dirname(foundConfigPath) }); | ||
nebula_core_1.trace('Platform module config validation...'); | ||
validatedConfig = await config.validate(); | ||
nebula_core_1.trace(JSON.stringify(validatedConfig)); | ||
} | ||
else { | ||
nebula_core_1.handleError(err); | ||
nebula_core_1.error(`Config must be valid JSON or YAML`); | ||
} | ||
} | ||
catch (err) { | ||
nebula_core_1.trace(`Config validation failed`); | ||
nebula_core_1.handleError(err); | ||
} | ||
if (validatedConfig) { | ||
@@ -63,0 +84,0 @@ // Init |
@@ -1,1 +0,1 @@ | ||
{"version":"0.0.7","commands":{"platform:start":{"id":"platform:start","description":"Initiates the local deployment of a Nebula compatible project","pluginName":"@rocketmakers/nebula-platform","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"config":{"name":"config","type":"option","char":"c","description":"Location of the Nebula config JSON. If not specified, it looks for a nebula.json in the current working directory"},"loglevel":{"name":"loglevel","type":"option","char":"l","description":"Log level of display output","helpValue":"(fatal|error|warn|info|trace|debug)","options":["fatal","error","warn","info","trace","debug"],"default":"info"},"root":{"name":"root","type":"option","char":"r","description":"Location of the project root","default":"."}},"args":[{"name":"file"}]}}} | ||
{"version":"0.0.8","commands":{"platform:start":{"id":"platform:start","description":"Initiates the local deployment of a Nebula compatible project","pluginName":"@rocketmakers/nebula-platform","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false},"config":{"name":"config","type":"option","char":"c","description":"Location of the Nebula config JSON. If not specified, it looks for a nebula.json in the current working directory"},"loglevel":{"name":"loglevel","type":"option","char":"l","description":"Log level of display output","helpValue":"(fatal|error|warn|info|trace|debug)","options":["fatal","error","warn","info","trace","debug"],"default":"info"},"root":{"name":"root","type":"option","char":"r","description":"Location of the project root","default":"."}},"args":[{"name":"file"}]}}} |
{ | ||
"name": "@rocketmakers/nebula-platform", | ||
"description": "Nebula CLI plugin for providing a platform for rocketmakers projects", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"author": "Jonny <jonny.green@rocketmakers.com>", | ||
@@ -11,3 +11,3 @@ "bugs": "https://gitlab.com/jonnydg/nebula/issues", | ||
"@rocketmakers/log": "^0.1.0", | ||
"@rocketmakers/nebula-core": "^0.0.7", | ||
"@rocketmakers/nebula-core": "^0.0.8", | ||
"@rocketmakers/shell-commands": "^0.1.20", | ||
@@ -68,3 +68,3 @@ "@rocketmakers/validation": "^0.1.12", | ||
}, | ||
"gitHead": "16fc385af739a72da57196f0138e9dbd3bea1b28" | ||
"gitHead": "f9c73961a0948266a53553992f94cfbd75a64890" | ||
} |
@@ -28,3 +28,3 @@ nebula-platform | ||
$ nebula (-v|--version|version) | ||
@rocketmakers/nebula-platform/0.0.7 linux-x64 node-v12.14.0 | ||
@rocketmakers/nebula-platform/0.0.8 linux-x64 node-v12.14.0 | ||
$ nebula --help [COMMAND] | ||
@@ -59,3 +59,3 @@ USAGE | ||
_See code: [lib/commands/platform/start.js](https://gitlab.com/jonnydg/nebula/blob/v0.0.7/lib/commands/platform/start.js)_ | ||
_See code: [lib/commands/platform/start.js](https://gitlab.com/jonnydg/nebula/blob/v0.0.8/lib/commands/platform/start.js)_ | ||
<!-- commandsstop --> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
221206
3103
0
+ Added@rocketmakers/nebula-core@0.0.8(transitive)
- Removed@rocketmakers/nebula-core@0.0.7(transitive)