drmabuse23 / generator-ionic-2 Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Add some github pages would be nice
$ yo ionic-2
Welcome to generator-ionic-2! v. 0.1.3-beta
init
{ [CordovaError: You need to qualify add
or remove
with one or more platforms!]
name: 'CordovaError',
message: 'You need to qualify add
or remove
with one or more platforms!',
code: 0,
context: undefined }
$ cordova -v
5.4.1
$ yo --version
1.5.0
$ npm --version
3.5.1
Transpiled index.js using babel (babel: 5.8.34 - latest 5.x)
npm install [email protected] --save
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
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 _get = function get(_x4, _x5, _x6) { var _again = true; _function: while (_again) { var object = _x4, property = _x5, receiver = _x6; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x4 = parent; _x5 = property; _x6 = receiver; _again = true; desc = parent = undefined; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var _os = require('os');
var _os2 = _interopRequireDefault(_os);
var _yeomanGenerator = require('yeoman-generator');
var _yeomanWelcome = require('yeoman-welcome');
var _yeomanWelcome2 = _interopRequireDefault(_yeomanWelcome);
var _chalk = require('chalk');
var _chalk2 = _interopRequireDefault(_chalk);
var _lodash = require('lodash');
var _lodash2 = _interopRequireDefault(_lodash);
var _fs = require('fs');
var _fs2 = _interopRequireDefault(_fs);
var _cordovaLib = require('cordova-lib');
var _cordovaLib2 = _interopRequireDefault(_cordovaLib);
var _utilsValidate = require('./../utils/Validate');
var _utilsValidate2 = _interopRequireDefault(_utilsValidate);
var _utilsPlugins = require('./../utils/Plugins');
var _utilsPlugins2 = _interopRequireDefault(_utilsPlugins);
/**
* Base Generator class to creat a empty project
*/
require("babel-polyfill");
var GeneratorIonic2 = (function (_Base) {
_inherits(GeneratorIonic2, _Base);
function GeneratorIonic2() {
_classCallCheck(this, GeneratorIonic2);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_get(Object.getPrototypeOf(GeneratorIonic2.prototype), 'constructor', this).apply(this, args);
var plug = new _utilsPlugins2['default']();
this.pkg = require(this.sourceRoot() + '/../../../package.json');
this.options = {
name: 'test-app',
id: 'com.ionic2.gen.nice',
version: '0.0.1',
description: 'My Ionic 2 App',
email: '[email protected]',
url: 'https://github.com/DrMabuse23/generator-ionic-2',
author: 'DrMabuse'
};
this.answers = null;
this.platforms = ['ios', 'android'];
if (_os2['default'].platform !== 'darwin') {
this.platforms.push('windows');
}
this.plugins = plug.getPlugins();
this.genPrompts = [];
}
/**
* create the basic prompts for the empty app creation
* @return {Array} []
*/
_createClass(GeneratorIonic2, [{
key: 'getStartPrompts',
value: function getStartPrompts() {
var _this = this;
var keys = Object.keys(this.options);
keys.forEach(function (option, key) {
_this.genPrompts.push({
type: 'input',
name: option,
message: 'Enter a ' + option + ' for your app:',
'default': _this.options[option]
});
if (typeof _utilsValidate2['default'][option] === 'function') {
_this.genPrompts[key].validate = _utilsValidate2['default'][option];
}
});
this.genPrompts.push({
type: 'checkbox',
name: 'platforms',
message: 'Please choose a Platform',
choices: this.platforms
});
this.genPrompts.push({
type: 'checkbox',
name: 'plugins',
message: 'Please choose your Plugins',
choices: this.plugins
});
}
/**
* copy some files from root to destination
*/
}, {
key: '_copy',
value: function _copy() {
var file = arguments.length <= 0 || arguments[0] === undefined ? undefined : arguments[0];
if (!file) {
return false;
}
if (file === 'scripts') {
return this.fs.copy(this.templatePath('' + file), this.destinationPath(file), function (err) {
throw Error(err);
});
}
return this.fs.copy(this.templatePath('_' + file), this.destinationPath(file), function (err) {
throw Error(err);
});
}
/**
* create som templates with the params
*/
}, {
key: 'createTemplate',
value: function createTemplate() {
var file = arguments.length <= 0 || arguments[0] === undefined ? undefined : arguments[0];
var options = arguments.length <= 1 || arguments[1] === undefined ? undefined : arguments[1];
if (!file) {
return false;
}
return this.fs.copyTpl(this.templatePath('_' + file), this.destinationPath(file), options);
}
/**
* yeoman use this like a constructor
*/
}, {
key: 'init',
value: function init() {
this.fileCount = _fs2['default'].readdirSync('.').length;
// // abort when directory is not empty on first run
if (this.fileCount > 0) {
this.log(_chalk2['default'].red('Non-empty directory. Cordova needs an empty directory to set up project'));
process.exit(1);
}
// console.log('cordova', cordova);
this.getStartPrompts();
this.log(_yeomanWelcome2['default']);
this.log('Welcome to ' + _chalk2['default'].yellow.bold(this.pkg.name) + '! v. ' + _chalk2['default'].red(this.pkg.version));
}
/**
* question prompting
*/
}, {
key: 'prompting',
value: function prompting() {
var _this2 = this;
var done = this.async();
this.prompt(this.genPrompts, function (answers) {
_this2.answers = answers;
done();
});
}
/**
* create a cordova project into the destination folder
*/
}, {
key: '_initCordovaProject',
value: function _initCordovaProject() {
console.log('init');
return _cordovaLib2['default'].cordova.raw.create('.', this.answers.id, this.answers.name, this.answers.name).then(function () {
return true;
})['catch'](function (err) {
console.log(err);
process.exit();
});
}
/**
* add one or many platforms to the destination
*/
}, {
key: '_addPlatforms',
value: function _addPlatforms() {
var _this3 = this;
return _cordovaLib2['default'].cordova.raw.platform('add', this.answers.platforms, { save: true }).then(function () {
console.log('add platforms ' + _this3.answers.platforms);
return true;
})['catch'](function (err) {
console.log(err);
process.exit();
});
}
/**
* add one or more Plugins to the destination
*/
}, {
key: '_addPlugins',
value: function _addPlugins() {
var _this4 = this;
return _cordovaLib2['default'].cordova.raw.plugin('add', this.answers.plugins, { save: true }).then(function () {
console.log('add plugins ' + _this4.answers.plugins);
return true;
})['catch'](function (err) {
console.log(err);
process.exit();
});
}
/**
* copy the ionic2angular stuff starter template
*/
}, {
key: '_createIonicApp',
value: function _createIonicApp() {
var _this5 = this;
['.gitignore', 'app', 'scripts', 'resources', 'tsconfig.json', 'gulpfile.js', 'webpack.config.js', 'webpack.production.config.js'].forEach(function (file) {
_this5._copy(file);
});
['package.json'].forEach(function (file) {
_this5.createTemplate(file, _this5.answers);
});
}
/**
* promise the writing process
*/
}, {
key: 'writing',
value: function writing() {
var _this6 = this;
var done = this.async();
this._initCordovaProject().then(function () {
_this6._addPlatforms().then(function () {
_this6._addPlugins().then(function () {
_this6._createIonicApp();
done();
});
});
});
}
/**
* npm install after create the app
*/
}, {
key: 'install',
value: function install() {
var _this7 = this;
var done = this.async();
return new Promise(function (resolve, reject) {
var i = 0;
_this7.log('☕ ☕ ☕ ☕ ☕ Start npm install ☕ ☕ ☕ ☕ ☕');
var process = _this7.spawnCommand('npm', ['install']);
process.on('close', function (code, signal) {
resolve(code);
done();
});
});
}
}]);
return GeneratorIonic2;
})(_yeomanGenerator.Base);
exports['default'] = GeneratorIonic2;
module.exports = exports['default'];
Transpiled index.js using babel (babel-cli: 6.3.17 - latest)
npm install babel-cli --save
npm install babel-preset-es2015 --save
{
"presets": [
"es2015"
]
}
'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; }; })();
Object.defineProperty(exports, "__esModule", {
value: true
});
var _os = require('os');
var _os2 = _interopRequireDefault(_os);
var _yeomanGenerator = require('yeoman-generator');
var _yeomanWelcome = require('yeoman-welcome');
var _yeomanWelcome2 = _interopRequireDefault(_yeomanWelcome);
var _chalk = require('chalk');
var _chalk2 = _interopRequireDefault(_chalk);
var _lodash = require('lodash');
var _lodash2 = _interopRequireDefault(_lodash);
var _fs = require('fs');
var _fs2 = _interopRequireDefault(_fs);
var _cordovaLib = require('cordova-lib');
var _cordovaLib2 = _interopRequireDefault(_cordovaLib);
var _Validate = require('./../utils/Validate');
var _Validate2 = _interopRequireDefault(_Validate);
var _Plugins = require('./../utils/Plugins');
var _Plugins2 = _interopRequireDefault(_Plugins);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
require("babel-polyfill");
/**
* Base Generator class to creat a empty project
*/
var GeneratorIonic2 = (function (_Base) {
_inherits(GeneratorIonic2, _Base);
function GeneratorIonic2() {
var _Object$getPrototypeO;
_classCallCheck(this, GeneratorIonic2);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
var _this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(GeneratorIonic2)).call.apply(_Object$getPrototypeO, [this].concat(args)));
var plug = new _Plugins2.default();
_this.pkg = require(_this.sourceRoot() + '/../../../package.json');
_this.options = {
name: 'test-app',
id: 'com.ionic2.gen.nice',
version: '0.0.1',
description: 'My Ionic 2 App',
email: '[email protected]',
url: 'https://github.com/DrMabuse23/generator-ionic-2',
author: 'DrMabuse'
};
_this.answers = null;
_this.platforms = ['ios', 'android'];
if (_os2.default.platform !== 'darwin') {
_this.platforms.push('windows');
}
_this.plugins = plug.getPlugins();
_this.genPrompts = [];
// greet and shit
_this._init();
_this._getStartPrompts();
return _this;
}
/**
* create the basic prompts for the empty app creation
* @return {Array} []
*/
_createClass(GeneratorIonic2, [{
key: '_getStartPrompts',
value: function _getStartPrompts() {
var _this2 = this;
var keys = Object.keys(this.options);
keys.forEach(function (option, key) {
_this2.genPrompts.push({
type: 'input',
name: option,
message: 'Enter a ' + option + ' for your app:',
default: _this2.options[option]
});
if (typeof _Validate2.default[option] === 'function') {
_this2.genPrompts[key].validate = _Validate2.default[option];
}
});
this.genPrompts.push({
type: 'checkbox',
name: 'platforms',
message: 'Please choose a Platform',
choices: this.platforms
});
this.genPrompts.push({
type: 'checkbox',
name: 'plugins',
message: 'Please choose your Plugins',
choices: this.plugins
});
}
/**
* copy some files from root to destination
*/
}, {
key: '_copy',
value: function _copy() {
var file = arguments.length <= 0 || arguments[0] === undefined ? undefined : arguments[0];
if (!file) {
return false;
}
if (file === 'scripts') {
return this.fs.copy(this.templatePath('' + file), this.destinationPath(file), function (err) {
throw Error(err);
});
}
return this.fs.copy(this.templatePath('_' + file), this.destinationPath(file), function (err) {
throw Error(err);
});
}
/**
* create som templates with the params
*/
}, {
key: 'createTemplate',
value: function createTemplate() {
var file = arguments.length <= 0 || arguments[0] === undefined ? undefined : arguments[0];
var options = arguments.length <= 1 || arguments[1] === undefined ? undefined : arguments[1];
if (!file) {
return false;
}
return this.fs.copyTpl(this.templatePath('_' + file), this.destinationPath(file), options);
}
/**
* yeoman use this like a constructor
*/
}, {
key: '_init',
value: function _init() {
this.fileCount = _fs2.default.readdirSync('.').length;
// abort when directory is not empty on first run
if (this.fileCount > 0) {
this.log(_chalk2.default.red('Non-empty directory. Cordova needs an empty directory to set up project'));
process.exit(1);
}
// console.log('cordova', cordova);
this.log(_yeomanWelcome2.default);
this.log('Welcome to ' + _chalk2.default.yellow.bold(this.pkg.name) + '! v. ' + _chalk2.default.red(this.pkg.version));
}
/**
* question prompting
*/
}, {
key: 'prompting',
value: function prompting() {
var _this3 = this;
var done = this.async();
this.prompt(this.genPrompts, function (answers) {
_this3.answers = answers;
done();
});
}
/**
* create a cordova project into the destination folder
*/
}, {
key: '_initCordovaProject',
value: function _initCordovaProject() {
return _cordovaLib2.default.cordova.raw.create('.', this.answers.id, this.answers.name, this.answers.name).then(function () {
return true;
}).catch(function (err) {
console.log(err.message);
// process.exit();
return err;
});
}
/**
* add one or many platforms to the destination
*/
}, {
key: '_addPlatforms',
value: function _addPlatforms() {
var _this4 = this;
return _cordovaLib2.default.cordova.raw.platform('add', this.answers.platforms, { save: true }).then(function () {
console.log('add platforms ' + _this4.answers.platforms);
return true;
}).catch(function (err) {
console.log(err.message);
// process.exit();
return err;
});
}
/**
* add one or more Plugins to the destination
*/
}, {
key: '_addPlugins',
value: function _addPlugins() {
var _this5 = this;
return _cordovaLib2.default.cordova.raw.plugin('add', this.answers.plugins, { save: true }).then(function () {
console.log('add plugins ' + _this5.answers.plugins);
return true;
}).catch(function (err) {
console.log(err.message);
// process.exit();
return err;
});
}
/**
* copy the ionic2angular stuff starter template
*/
}, {
key: '_createIonicApp',
value: function _createIonicApp() {
var _this6 = this;
['.gitignore', 'app', 'scripts', 'resources', 'tsconfig.json', 'gulpfile.js', 'webpack.config.js', 'webpack.production.config.js'].forEach(function (file) {
_this6._copy(file);
});
['package.json'].forEach(function (file) {
_this6.createTemplate(file, _this6.answers);
});
}
/**
* promise the writing process
*/
}, {
key: 'writing',
value: function writing() {
var _this7 = this;
var done = this.async();
this._initCordovaProject().then(function () {
_this7._addPlatforms().then(function () {
_this7._addPlugins();
});
})
// no matter what we've picked by cordova selections (or if we
// picked no platforms or plugins, we'll continue execution)
.finally(function () {
_this7._createIonicApp();
done();
});
}
/**
* npm install after create the app
*/
}, {
key: 'install',
value: function install() {
var _this8 = this;
var done = this.async();
return new Promise(function (resolve, reject) {
var i = 0;
_this8.log('☕ ☕ ☕ ☕ ☕ Start npm install ☕ ☕ ☕ ☕ ☕');
var process = _this8.spawnCommand('npm', ['install']);
process.on('close', function (code, signal) {
resolve(code);
done();
});
});
}
}]);
return GeneratorIonic2;
})(_yeomanGenerator.Base);
exports.default = GeneratorIonic2;
(node-v4.4.3) axelor@ws04:~/Projects/Axelor/mytodo$ yo ionic-2
module.js:327
throw err;
^
Error: Cannot find module './../../core/plugins.json'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at new PluginsBook (/home/axelor/node_modules/generator-ionic-2/generators/utils/Plugins.js:29:20)
at new GeneratorIonic2 (/home/axelor/node_modules/generator-ionic-2/generators/app/index.js:67:16)
at Environment.instantiate (/home/axelor/opt/node/4.4.3/lib/node_modules/yo/node_modules/yeoman-environment/lib/environment.js:328:10)
at Environment.create (/home/axelor/opt/node/4.4.3/lib/node_modules/yo/node_modules/yeoman-environment/lib/environment.js:305:15)
at Environment.run (/home/axelor/opt/node/4.4.3/lib/node_modules/yo/node_modules/yeoman-environment/lib/environment.js:364:24)
at /home/axelor/opt/node/4.4.3/lib/node_modules/yo/lib/cli.js:131:11
npm start
I get the following result
[474] ./app/main/main.scss 1.47 kB {0} [built] [1 error]
[476] ./~/style-loader/addStyles.js 7.21 kB {0} [built]
+ 1 hidden modules
WARNING in ./~/css-loader?sourceMap!./~/resolve-url-loader!./~/autoprefixer-loader?browsers=last 2 version!./~/sass-loader?sourceMap!./app/main/main.scss
resolve-url-loader cannot operate: source-map error
Cannot call method 'map' of undefined
ERROR in ./~/css-loader?sourceMap!./~/resolve-url-loader!./~/autoprefixer-loader?browsers=last 2 version!./~/sass-loader?sourceMap!./app/main/main.scss
Module build failed: ReferenceError: Promise is not defined
at LazyResult.async (/home/django/www/anio/alliance/node_modules/postcss/lib/lazy-result.js:157:31)
at LazyResult.then (/home/django/www/anio/alliance/node_modules/postcss/lib/lazy-result.js:79:21)
at processCss (/home/django/www/anio/alliance/node_modules/css-loader/lib/processCss.js:181:5)
at Object.module.exports (/home/django/www/anio/alliance/node_modules/css-loader/lib/loader.js:24:2)
@ ./app/main/main.scss 4:14-264 13:2-17:4 14:20-270
webpack: bundle is now VALID.
yeoman-welcome, babel-polyfill, lodash add description for add webpack for global
Find out why the plugins are not save in the config.xml
at the moment we have a only a cli for nerds maybe its better to add something for beginners
got this error when npm start
:
WARNING in ./~/css-loader?sourceMap!./~/resolve-url-loader!./~/autoprefixer-loader?browsers=last 2 version!./~/sass-loader?sourceMap!./app/main/main.scss
resolve-url-loader cannot operate: source-map error
Cannot read property 'map' of undefined
webpack: bundle is now VALID.
Can you help me with this error please?
ERROR in ./~/css-loader?sourceMap!./~/resolve-url-loader!./~/autoprefixer-loader?browsers=last 2 version!./~/sass-loader?sourceMap!./app/main/main.scss
Module build failed:
@import "../../node-modules/ionic-framework/ionic.ios";
^
File to import not found or unreadable: ../../node-modules/ionic-framework/ionic.ios
Parent style sheet: stdin
in /Users/gutomec/www/myApp_ionic_2/app/main/main.scss (line 51, column 1)
@ ./app/main/main.scss 4:14-264 13:2-17:4 14:20-270
main.scss
$font-path: '../../node-modules/ionic-framework/fonts';
$ionicons-font-path: $font-path;
// Ionic Sass
// ---------------------------------
@import "../../node-modules/ionic-framework/ionic.ios";
//@import "~ionic-framework/ionic.md";
// App Sass
// ---------------------------------
@import "../about/about", "../device/device";
BR,
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.