diff --git a/meteor/README.md b/meteor/README.md deleted file mode 100644 index c4f742e73..000000000 --- a/meteor/README.md +++ /dev/null @@ -1,38 +0,0 @@ -[Semantic-UI](http://semantic-ui.com/) packaged for [Meteor.js](http://meteor.com). - -# Usage - -```sh -meteor add semantic:ui -``` - -# Theming - -In case you wish to build your own theme you should follow the -[Recommended Usage (Themed)](https://github.com/Semantic-Org/Semantic-UI#recommended-usage-themed) -guide. - -After having build the project you'll get a ready to use meteor package -shipping your newly created theme. -Simply move the whole folder (or otherwise simlink it...) under your Meteor -app's `packages` folder run - -```sh -meteor add semantic:ui -``` - -from your app's main folder and that's it! - - -# Issues - -If you encounter a Meteor-related issue while using this package, -please CC @Semantic-Org/meteor when you -[file it](https://github.com/Semantic-Org/Semantic-UI/issues). - - -# Meteor - -If you're new to Meteor, here's what the excitement is all about - [watch the first two minutes](https://www.youtube.com/watch?v=fsi0aJ9yr2o); you'll be hooked by 1:28. - -That screencast is from 2012. In the meantime, Meteor has become a mature JavaScript-everywhere web development framework with numerous [advantages](http://www.meteorpedia.com/read/Why_Meteor) over all other single-page application frameworks. diff --git a/package.json b/package.json index 11c3410d2..0293863c2 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "gulp-util": "^3.0.1", "gulp-watch": "^2.0.0", "karma": "^0.12.28", + "require-dot-file": "^0.2.3", "rtlcss": "^1.4.2", "run-sequence": "^1.0.2", "wrench": "^1.5.8" diff --git a/tasks/config/project/install.js b/tasks/config/project/install.js index 4b3cb4606..c64a5b934 100644 --- a/tasks/config/project/install.js +++ b/tasks/config/project/install.js @@ -25,8 +25,12 @@ var when = { // install hasConfig: function() { - return( fs.existsSync('./semantic.json') ); + return requireDotFile('semantic.json'); }, + hasThemeFile: function() { + return true; + }, + allowOverwrite: function(questions) { return (questions.overwrite === undefined || questions.overwrite == 'yes'); }, @@ -72,7 +76,7 @@ module.exports = { // check whether install is setup isSetup: function() { - return true; + return (when.hasThemeFile && when.hasConfig); }, // checks if files are in a PM directory @@ -124,6 +128,63 @@ module.exports = { return walk(directory); }, + createJSON: function(answers) { + var + json = { + paths: { + source: {}, + output: {} + } + } + ; + + // add path to semantic + if(answers.semanticRoot) { + json.base = answers.semanticRoot; + } + + // add components + if(answers.components) { + json.components = answers.components; + } + + // add permissions + if(answers.permission) { + json.permission = answers.permission; + } + + // add dist folder paths + if(answers.dist) { + answers.dist = answers.dist; + json.paths.output = { + packaged : answers.dist + '/', + uncompressed : answers.dist + '/components/', + compressed : answers.dist + '/components/', + themes : answers.dist + '/themes/' + }; + } + + // add rtl choice + if(answers.rtl) { + json.rtl = answers.rtl; + } + + // add site path + if(answers.site) { + json.paths.source.site = answers.site + '/'; + } + if(answers.packaged) { + json.paths.output.packaged = answers.packaged + '/'; + } + if(answers.compressed) { + json.paths.output.compressed = answers.compressed + '/'; + } + if(answers.uncompressed) { + json.paths.output.uncompressed = answers.uncompressed + '/'; + } + return json; + }, + // files cleaned up after install setupFiles: [ './src/theme.config.example', @@ -137,20 +198,26 @@ module.exports = { theme : 'src/theme.config' }, - // modified to create configs - templates: { - config : 'semantic.json.example', - site : './src/_site', - theme : './src/theme.config.example' + // source paths (inside PM folder) + source: { + config : './semantic.json.example', + definitions : './src/definitions', + gulpFile : './gulpfile.js', + modules : './node_modules/', + site : './src/_site', + themes : './src/themes', + themeConfig : './src/theme.config.example' }, - // folder paths + // folder paths to files relative to root folders: { + modules: './node_modules/', config : './', site : './src/site', theme : './src/' }, + // questions asked during install questions: { root: [ @@ -161,7 +228,7 @@ module.exports = { ' \n' + ' {packageMessage} \n' + ' \n' + - ' Is this your project\'s root (where gulp will be run)?\n' + + ' Is this your project folder?\n' + ' \033[92m{root}\033[0m \n' + ' \n ' + '\n', @@ -179,14 +246,14 @@ module.exports = { { type : 'input', name : 'customRoot', - message : 'Please enter the path to your project root folder (where build tools will be run)', + message : 'Please enter the absolute path to your project root', default : './', when : when.changeRoot }, { type : 'input', - name : 'sourceFolder', - message : 'Where should we put Semantic UI inside your project folder?', + name : 'semanticRoot', + message : 'Where should we put Semantic UI inside your project?', default : 'semantic/' } ], @@ -606,7 +673,23 @@ module.exports = { /* Copy Install Folders */ wrench: { - recursive: { + + // copy during npm update (default theme / definition) + update: { + forceDelete : true, + excludeHiddenUnix : true, + preserveFiles : false + }, + + // copy for node_modules + modules: { + forceDelete : true, + excludeHiddenUnix : true, + preserveFiles : false + }, + + // copy for site theme + site: { forceDelete : true, excludeHiddenUnix : true, preserveFiles : true diff --git a/tasks/install.js b/tasks/install.js index 2ce19e0a4..911d9ae3d 100644 --- a/tasks/install.js +++ b/tasks/install.js @@ -26,10 +26,13 @@ var // install config install = require('./config/project/install'), + release = require('./config/project/release'), // shorthand questions = install.questions, - settings = install.settings + folders = install.folders, + settings = install.settings, + source = install.source ; @@ -38,7 +41,7 @@ module.exports = function () { /*-------------- - PM Detection + Install Tools ---------------*/ var @@ -47,31 +50,35 @@ module.exports = function () { rootQuestions = questions.root ; - // test conditions REMOVE - currentConfig = false; - console.clear(); + // debug manager = { - name: 'NPM', - root: __dirname + name : 'NPM', + root : path.normalize(__dirname + '/../') }; - if(manager && !currentConfig) { - // PM Detected & First Run - rootQuestions[0].message = rootQuestions[0].message - .replace('{packageMessage}', 'We detected you are using \033[92m' + manager.name + '\033[0m. Nice! ') - .replace('{root}', manager.root) - ; - rootQuestions[0].default = manager.root; - } - else if(currentConfig) { - // Not First Run - rootQuestions = []; + if(manager == 'NPM') { + // PM that supports Build Tools + + if(currentConfig) { + // Upgrade run + rootQuestions = []; + } + else { + // First Run + rootQuestions[0].message = rootQuestions[0].message + .replace('{packageMessage}', 'We detected you are using \033[92m' + manager.name + '\033[0m. Nice! ') + .replace('{root}', manager.root) + ; + // set default path to detected PM root + rootQuestions[0].default = manager.root; + rootQuestions[1].default = manager.root; + } } else { - // No PM / First Run (Remove PM Question) - rootQuestions.shift(); + // Unsupported package manager + rootQuestions = []; } // insert root questions after "Install Type" question @@ -79,38 +86,42 @@ module.exports = function () { Array.prototype.splice.apply(questions.setup, [2, 0].concat(rootQuestions)); } + /*-------------- - Inquire + NPM Update ---------------*/ - return gulp - .src('gulpfile.js') - .pipe(prompt.prompt(questions.setup, function(answers) { - var - siteVariable = /@siteFolder .*\'(.*)/mg, - siteDestination = answers.site || install.folders.site, + if(currentConfig && manager === 'NPM') { - pathToSite = path.relative(path.resolve(install.folders.theme), path.resolve(siteDestination)).replace(/\\/g,'/'), - sitePathReplace = "@siteFolder : '" + pathToSite + "/';", + var + definitionPath = path.join(manager.root, currentConfig.base + currentConfig.source.definitions), + themePath = path.join(manager.root, currentConfig.base + currentConfig.source.themes), + siteThemePath = path.join(manager.root, currentConfig.base + currentConfig.source.site) + ; - configExists = fs.existsSync(config.files.config), - themeConfigExists = fs.existsSync(config.files.theme), - siteExists = fs.existsSync(siteDestination), + console.info('Updating ui definitions to ' + release.version); + wrench.copyDirSyncRecursive(source.definitions, definitionPath, settings.wrench.update); - // file that will be modified - jsonSource = (configExists) - ? config.files.config - : install.templates.config, + console.info('Updating default theme to' + release.version); + wrench.copyDirSyncRecursive(source.themes, themePath, settings.wrench.update); - json = { - paths: { - source: {}, - output: {} - } - } - ; + wrench.copyDirSyncRecursive(source.site, siteThemePath, settings.wrench.site); + } + + + /*-------------- + Set-up + ---------------*/ + + return gulp + .src('gulpfile.js') + .pipe(prompt.prompt(questions.setup, function(answers) { + + /*-------------- + Exit Conditions + ---------------*/ - // exit if config exists and user specifies not to proceed + // if config exists and user specifies not to proceed if(answers.overwrite !== undefined && answers.overwrite == 'no') { return; } @@ -120,18 +131,63 @@ module.exports = function () { console.log('------------------------------'); /*-------------- - PM Mods + Install Tools ---------------*/ - // (All cases) Copy node_modules folder, if it isnt current folder + // We're moving things around + if(answers.root || answers.customRoot) { + + var + gulpRoot, + gulpFileExists + ; + + // Set root to custom root path + if(answers.customRoot) { + answers.root = answers.customRoot; + } + + // add project root to semantic root + if(answers.semanticRoot) { + answers.semanticRoot = path.join(answers.root, answers.semanticRoot); + } + + // Copy build tools to gulp root (node_modules & gulpfile) + if(answers.semanticRoot) { + + // copy gulp node_modules + console.info('Copying dependencies', answers.semanticRoot + folders.modules); + wrench.copyDirSyncRecursive(source.modules, answers.semanticRoot + folders.modules, settings.wrench.modules); - // (PM Case) Copy src/ to project root + // create gulp file + console.info('Creating gulp-file.js'); + gulp.src(source.gulpFile) + .pipe(plumber()) + .pipe(gulp.dest(answers.semanticRoot)) + ; + + + } + + + } /*-------------- Site Themes ---------------*/ + var + siteVariable = /@siteFolder .*\'(.*)/mg, + siteDestination = answers.site || folders.site, + + siteExists = fs.existsSync(siteDestination), + themeConfigExists = fs.existsSync(config.files.theme), + + pathToSite = path.relative(path.resolve(folders.theme), path.resolve(siteDestination)).replace(/\\/g,'/'), + sitePathReplace = "@siteFolder : '" + pathToSite + "/';" + ; + // create site files if(siteExists) { console.info('Site folder exists, merging files (no overwrite)', siteDestination); @@ -141,28 +197,25 @@ module.exports = function () { } // Copy _site template without overwrite - wrench.copyDirSyncRecursive(install.templates.site, siteDestination, settings.wrench.recursive); + wrench.copyDirSyncRecursive(source.site, siteDestination, settings.wrench.site); - /*-------------- - Theme.config - ---------------*/ - // Adjust LESS variables for site folder location + // Adjust theme.less in project folder console.info('Adjusting @siteFolder', sitePathReplace); if(themeConfigExists) { gulp.src(config.files.site) .pipe(plumber()) .pipe(replace(siteVariable, sitePathReplace)) - .pipe(gulp.dest(install.folders.theme)) + .pipe(gulp.dest(folders.theme)) ; } else { console.info('Creating src/theme.config (LESS config)'); - gulp.src(install.templates.theme) + gulp.src(source.themeConfig) .pipe(plumber()) .pipe(rename({ extname : '' })) .pipe(replace(siteVariable, sitePathReplace)) - .pipe(gulp.dest(install.folders.theme)) + .pipe(gulp.dest(folders.theme)) ; } @@ -170,44 +223,15 @@ module.exports = function () { Semantic.json ---------------*/ - // add components - if(answers.components) { - json.components = answers.components; - } - // add permissions - if(answers.permission) { - json.permission = answers.permission; - } - - // add dist folder paths - if(answers.dist) { - answers.dist = answers.dist; - json.paths.output = { - packaged : answers.dist + '/', - uncompressed : answers.dist + '/components/', - compressed : answers.dist + '/components/', - themes : answers.dist + '/themes/' - }; - } - // add rtl choice - if(answers.rtl) { - json.rtl = answers.rtl; - } - // add site path - if(answers.site) { - json.paths.source.site = answers.site + '/'; - } - if(answers.packaged) { - json.paths.output.packaged = answers.packaged + '/'; - } - if(answers.compressed) { - json.paths.output.compressed = answers.compressed + '/'; - } - if(answers.uncompressed) { - json.paths.output.uncompressed = answers.uncompressed + '/'; - } + var + configExists = fs.existsSync(config.files.config), + json = install.createJSON(answers), + jsonSource = (configExists) + ? config.files.config + : source.config + ; - // write semantic.json + // adjust variables in theme.less if(configExists) { console.info('Extending config file (semantic.json)'); gulp.src(jsonSource)