@mobify/generator
Advanced tools
Comparing version
@@ -7,3 +7,3 @@ 'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); // eslint-disable-line no-unused-vars | ||
@@ -14,2 +14,12 @@ var _inquirer = require('inquirer'); | ||
var _colors = require('colors'); | ||
var _colors2 = _interopRequireDefault(_colors); | ||
var _api = require('./api'); | ||
var _api2 = _interopRequireDefault(_api); | ||
var _questions = require('./questions'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -23,83 +33,66 @@ | ||
this.questions = [{ | ||
type: 'confirm', | ||
name: 'toBeDelivered', | ||
message: 'Is this for delivery?', | ||
default: false | ||
}, { | ||
type: 'input', | ||
name: 'phone', | ||
message: 'What\'s your phone number?', | ||
validate: function validate(value) { | ||
var pass = value.match(/^([01]{1})?[-.\s]?\(?(\d{3})\)?[-.\s]?(\d{3})[-.\s]?(\d{4})\s?((?:#|ext\.?\s?|x\.?\s?){1}(?:\d+)?)?$/i); | ||
if (pass) { | ||
return true; | ||
} | ||
return 'Please enter a valid phone number'; | ||
} | ||
}, { | ||
type: 'list', | ||
name: 'size', | ||
message: 'What size do you need?', | ||
choices: ['Large', 'Medium', 'Small'], | ||
filter: function filter(val) { | ||
return val.toLowerCase(); | ||
} | ||
}, { | ||
type: 'input', | ||
name: 'quantity', | ||
message: 'How many do you need?', | ||
validate: function validate(value) { | ||
var valid = !isNaN(parseFloat(value)); | ||
return valid || 'Please enter a number'; | ||
}, | ||
filter: Number | ||
}, { | ||
type: 'expand', | ||
name: 'toppings', | ||
message: 'What about the toppings?', | ||
choices: [{ | ||
key: 'p', | ||
name: 'Pepperoni and cheese', | ||
value: 'PepperoniCheese' | ||
}, { | ||
key: 'a', | ||
name: 'All dressed', | ||
value: 'alldressed' | ||
}, { | ||
key: 'w', | ||
name: 'Hawaiian', | ||
value: 'hawaiian' | ||
}] | ||
}, { | ||
type: 'rawlist', | ||
name: 'beverage', | ||
message: 'You also get a free 2L beverage', | ||
choices: ['Pepsi', '7up', 'Coke'] | ||
}, { | ||
type: 'input', | ||
name: 'comments', | ||
message: 'Any comments on your purchase experience?', | ||
default: 'Nope, all good!' | ||
}, { | ||
type: 'list', | ||
name: 'prize', | ||
message: 'For leaving a comment, you get a freebie', | ||
choices: ['cake', 'fries'], | ||
when: function when(answers) { | ||
return answers.comments !== 'Nope, all good!'; | ||
} | ||
}]; | ||
this.apiClient = new _api2.default(); | ||
} | ||
_createClass(CliSession, [{ | ||
key: 'prompt', | ||
value: function prompt() { | ||
console.log('Hi, welcome to Node Pizza'); | ||
key: 'transformQuestions', | ||
value: function transformQuestions(questionsDefinition) { | ||
var _this = this; | ||
return new Promise(function (resolve) { | ||
_this.questions = (0, _questions.transform)(questionsDefinition); | ||
resolve(); | ||
}); | ||
} | ||
}, { | ||
key: 'askQuestions', | ||
value: function askQuestions() { | ||
_inquirer2.default.prompt(this.questions).then(function (answers) { | ||
console.log('\nOrder receipt:'); | ||
console.log(JSON.stringify(answers, null, ' ')); | ||
console.log('TODO: actually call API to create a new project'); | ||
}); | ||
} | ||
}, { | ||
key: 'prompt', | ||
value: function prompt() { | ||
var _this2 = this; | ||
/* eslint-disable prefer-template */ | ||
console.log(' `:-.'); | ||
console.log(' -yyyyys+:`'); | ||
console.log(' /yyyyyyyyy` +o+/:-.'); | ||
console.log(' `oyyyyyyyyy- :hhhhhhhs'); | ||
console.log(' `syyyyyyyyy+ yhhhhhhhy'); | ||
console.log(' `-/oyyyyyyyyyyo :hhhhhhhhs'); | ||
console.log(' -/oyyyyyyyyyyyyyo` shhhhhhhhs'); | ||
console.log(' +yyyyyyyyyyyyyyyy+ `hhhhhhhhho'); | ||
console.log(' +yyyyyyyyyyyyyy+. .hhhhhhhhho'); | ||
console.log(' `yyyyyyyyys+/. yhhhhhhhhhs`'); | ||
console.log(' -yso+/-.` .yhhhhhhhhhy.'); | ||
console.log(' ```.....` `shhhhhhhhhy.'); | ||
console.log(' -://++++++++++++/-` /yhhhhhhhhy.'); | ||
console.log(' /++++++++++++++++++/. `ohhhhhhy+`'); | ||
console.log(' :++++++++++++++++++++/-` -shhs:`'); | ||
console.log(' `+++++++++++++++++++++++-` -`'); | ||
console.log(' `......-...-/+++++++++++/`'); | ||
console.log(' `-/+++++++:`'); | ||
console.log(' `.:/+:`'); | ||
console.log(''); | ||
console.log('Hey, you\'re about to create a new Mobify Platform project!'); | ||
console.log('We\'ll generate Progressive Web App with various components like Native Apps, Push messages, Analytics and more.'); | ||
console.log('You can find more info here: ' + 'https://docs.mobify.com'.underline); | ||
console.log(''); | ||
console.log('Before you get started:'.bold.yellow + ' make sure you\'ve created a new project in Mobify Cloud. ' + 'To create a Cloud project, visit this link: ' + 'https://cloud.mobify.com/projects/new/'.underline); | ||
console.log(''); | ||
/* eslint-disable prefer-template */ | ||
this.apiClient.getQuestions().then(function (questions) { | ||
return _this2.transformQuestions(questions); | ||
}).then(function () { | ||
return _this2.askQuestions(); | ||
}).catch(function (error) { | ||
console.error('Generator failed :-( Please try again later'); | ||
console.error(error); | ||
}); | ||
} | ||
}]); | ||
@@ -106,0 +99,0 @@ |
{ | ||
"name": "@mobify/generator", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"description": "Mobify Platform Generator", | ||
@@ -13,7 +13,8 @@ "main": "./lib/mobify.js", | ||
"scripts": { | ||
"build": "babel src --out-dir lib", | ||
"build": "babel src --out-dir lib && cp -R config lib", | ||
"prepublish": "npm run build", | ||
"start": "babel-node src/mobify.js", | ||
"lint": "eslint '**/*.js'", | ||
"test": "npm run lint" | ||
"test:unit": "mocha test --compilers js:babel-core/register", | ||
"test": "npm run lint && npm run test:unit" | ||
}, | ||
@@ -23,4 +24,12 @@ "babel": { | ||
"es2015" | ||
], | ||
"plugins": [ | ||
"transform-object-rest-spread" | ||
] | ||
}, | ||
"eslintConfig": { | ||
"env": { | ||
"node": true | ||
} | ||
}, | ||
"repository": { | ||
@@ -41,2 +50,4 @@ "type": "git", | ||
"babel-preset-es2015": "^6.24.1", | ||
"babel-plugin-transform-object-rest-spread": "^6.23.0", | ||
"chai": "^3.5.0", | ||
"eslint": "^3.19.0", | ||
@@ -46,8 +57,14 @@ "eslint-import-resolver-webpack": "^0.8.1", | ||
"mobify-code-style": "^2.7.4", | ||
"mocha": "^3.3.0", | ||
"webpack": "^2.3.3" | ||
}, | ||
"dependencies": { | ||
"colors": "^1.1.2", | ||
"commander": "^2.9.0", | ||
"inquirer": "^3.0.6" | ||
"inquirer": "^3.0.6", | ||
"nconf": "^0.8.4", | ||
"request": "^2.81.0", | ||
"request-promise-native": "^1.0.3", | ||
"validator": "^7.0.0" | ||
} | ||
} |
@@ -1,23 +0,10 @@ | ||
# 🏗️ Platform Generator | ||
# Platform Generator CLI | ||
Generate all the things! | ||
Make sure you have access to the Mobify [Platform Generator npm repo](https://www.npmjs.com/package/@mobify/generator). For that: | ||
``` | ||
888 | ||
888 | ||
888 | ||
.d88b. .d88b. 88888b. .d88b. 888d888 8888b. 888888 .d88b. 888d888 | ||
d88P"88b d8P Y8b 888 "88b d8P Y8b 888P" "88b 888 d88""88b 888P" | ||
888 888 88888888 888 888 88888888 888 .d888888 888 888 888 888 | ||
Y88b 888 Y8b. 888 888 Y8b. 888 888 888 Y88b. Y88..88P 888 | ||
"Y88888 "Y8888 888 888 "Y8888 888 "Y888888 "Y888 "Y88P" 888 | ||
888 | ||
Y8b d88P | ||
"Y88P" | ||
``` | ||
- `npm login` with your credentials | ||
- Ask Mobify to invite you as a collaborator to `@mobify/generator` | ||
Then simply run: | ||
# How to setup | ||
Make sure you have access to the Mobify [Platform Generator npm repo](https://www.npmjs.com/package/@mobify/generator). Then simply run | ||
``` | ||
@@ -33,2 +20,8 @@ npm install -g @mobify/generator | ||
or from the project files: | ||
``` | ||
npm start -- create | ||
``` | ||
# How to test | ||
@@ -42,6 +35,6 @@ | ||
Increase the version, then | ||
Increase the version in the `package.json`, then run: | ||
``` | ||
npm publish --access restricted | ||
npm publish | ||
``` | ||
@@ -48,0 +41,0 @@ |
Sorry, the diff of this file is not supported yet
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
16823
96.32%12
20%279
151.35%7
250%12
33.33%59
-10.61%1
Infinity%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added