Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving issue #39 and Issue #40 #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"commander": "^2.12.2",
"fs-extra": "^5.0.0",
"inquirer": "^4.0.1",
"inquirer-fuzzy-path": "^1.0.0",
"jsonfile": "^4.0.0",
"lodash": "^4.17.4"
},
Expand Down
10 changes: 7 additions & 3 deletions src/commands/add/prompts/add-element.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const { prompt } = require('inquirer');
const inquirer = require('inquirer');
inquirer.registerPrompt('fuzzypath', require('inquirer-fuzzy-path'));
//const { prompt } = require('inquirer');
const _ = require('lodash');
const writer = require('../../../utils/writer');

Expand Down Expand Up @@ -37,8 +39,10 @@ const questions = [
}
},
{
type: 'input',
type: 'fuzzypath',
name: 'icon_path',
default: 'icon.svg',
rootPath: '../',
message: 'Enter a path to a local directory where the icon is stored',
when: (answers) => answers.has_element_icon === 'Yes',
validate: value => iconValidator(value)
Expand Down Expand Up @@ -68,7 +72,7 @@ generateElementPath = (name) => {
}

module.exports = async (manifestModel) => {
let answers = await prompt(questions);
let answers = await inquirer.prompt(questions);
let settings;

if (answers.element_native_settings === 'Yes') {
Expand Down
Binary file added src/icons/appIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/dashboardCardIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/icons/elementIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 16 additions & 8 deletions src/models/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const _ = require('lodash');
const fs = require('fs');
const fse = require('fs-extra');
const jsonfile = require('jsonfile');
const path = require('path');

// CONSTANTS
// TODO: Implement these later to prevent bugs
Expand Down Expand Up @@ -91,16 +92,21 @@ module.exports = {
},

async moveIcon(iconPath, directory) {
if (!String.isString(iconPath) || !iconPath.endsWith('.svg')) {
throw 'ERROR: Icon must be an SVG.';
}
if(null === iconPath) {
iconPath = `${path.dirname(require.main.filename)}/src/icons/elementIcon.png`;
await fs.copyFileSync(iconPath, directory + '/icon.svg');
} else {
if (!_.isString(iconPath) || !iconPath.endsWith('.svg')) {
throw 'ERROR: Icon must be an SVG.';
}

let iconExists = await fs.existsSync(iconPath);
if (!iconExists) {
throw 'ERROR: Icon does not exist at the given path.';
}
let iconExists = await fs.existsSync(iconPath);
if (!iconExists) {
throw 'ERROR: Icon does not exist at the given path.';
}

await fs.copyFileSync(iconPath, directory + '/icon.svg');
await fs.copyFileSync(iconPath, directory + '/icon.svg');
}
},
async addElement(values, iconPath) {
if (!_.isArray(this.data.elements)) {
Expand All @@ -110,6 +116,8 @@ module.exports = {
await this.createElementDirectory(values.path);
if (_.isString(iconPath)) {
await this.moveIcon(iconPath, values.path);
} else {
await this.moveIcon(null, values.path);
}

this.data.elements.push(values);
Expand Down