Commit 5c328049 authored by Ken Hawkins's avatar Ken Hawkins
Browse files

Sneak in loads of linting between releases

parent 79c7800b
'use strict';
"use strict";
const fs = require('fs');
const path = require('path');
const gulp = require('gulp');
const fs = require("fs");
const path = require("path");
const gulp = require("gulp");
// Pull configuration from the package.json:
// const {componentPath, componentDirectories, buildDestionation} = require('../vf-config');
......@@ -14,4 +14,4 @@ const gulp = require('gulp');
// Not familiar with JS Modules? Don't fret, it can be a lot like wrapping code in a function; here's
// a nice quick start: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#Exporting_module_features
// require('./gulp-tasks/_gulp_rollup.js')(gulp, path, componentPath, componentDirectories, buildDestionation);
require(path.resolve('.', __dirname + '/node_modules/@visual-framework/vf-component-generator/gulp-tasks/vf-generator.js'))(gulp, path);
require(path.resolve(".", __dirname + "/node_modules/@visual-framework/vf-component-generator/gulp-tasks/vf-generator.js"))(gulp, path);
'use strict';
"use strict";
/**
* Expose vf-component gulp task as a JS module
......@@ -6,12 +6,12 @@
*/
module.exports = function(gulp, path) {
const shell = require('gulp-shell');
const shell = require("gulp-shell");
const generatorPath = path.resolve(__dirname, '..');
const generatorPath = path.resolve(__dirname, "..");
gulp.task('vf-component', shell.task(
['yo ' + generatorPath]
gulp.task("vf-component", shell.task(
["yo " + generatorPath]
));
return gulp;
......
'use strict';
"use strict";
const fs = require('fs');
const path = require('path');
const gulp = require('gulp');
const fs = require("fs");
const path = require("path");
const gulp = require("gulp");
// Pull configuration from the package.json:
// const {componentPath, componentDirectories, buildDestionation} = require('../vf-config');
......@@ -14,4 +14,4 @@ const gulp = require('gulp');
// Not familiar with JS Modules? Don't fret, it can be a lot like wrapping code in a function; here's
// a nice quick start: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#Exporting_module_features
// require('./gulp-tasks/_gulp_rollup.js')(gulp, path, componentPath, componentDirectories, buildDestionation);
require(path.resolve('.', __dirname + '/gulp-tasks/vf-generator.js'))(gulp, path);
require(path.resolve(".", __dirname + "/gulp-tasks/vf-generator.js"))(gulp, path);
var Generator = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
var path = require('path');
var config = require(path.resolve('.','package.json'));
var Generator = require("yeoman-generator");
var chalk = require("chalk");
var yosay = require("yosay");
var path = require("path");
var config = require(path.resolve(".","package.json"));
config.vfConfig = config.vfConfig || [];
vfName = config.vfConfig.vfName || "Visual Framework 2.0";
vfNamespace = config.vfConfig.vfNamespace || "vf-";
vfComponentPath = config.vfConfig.vfComponentPath || path.resolve(__dirname, '../../components');
vfComponentPath = config.vfConfig.vfComponentPath || path.resolve(__dirname, "../../components");
function camelize(str,upperCaseFirst) {
var upperCaseFirst = upperCaseFirst || false;
......@@ -17,26 +17,26 @@ function camelize(str,upperCaseFirst) {
} else {
return index === 0 ? word.toLowerCase() : word.toUpperCase();
}
}).replace(/\s+/g, '').replace(/-/g, '');
}).replace(/\s+/g, "").replace(/-/g, "");
}
module.exports = class extends Generator {
prompting() {
this.log((
chalk.blue.bold("_______ _______ __ __ _______ _______ __ _ _______ __ _ _______ \n") +
chalk.blue.bold("| || || |_| || || || | | || || | | || | \n") +
chalk.blue.bold("| || _ || || _ || _ || |_| || ___|| |_| ||_ _| \n") +
chalk.blue.bold("| || | | || || |_| || | | || || |___ | | | | \n") +
chalk.blue.bold("| _|| |_| || || ___|| |_| || _ || ___|| _ | | | \n") +
chalk.blue.bold("| |_ | || ||_|| || | | || | | || |___ | | | | | | \n") +
chalk.blue.bold("|_______||_______||_| |_||___| |_______||_| |__||_______||_| |__| |___| \n") +
chalk.red.bold("_______ _______ __ _ _______ ______ _______ _______ _______ ______ \n") +
chalk.red.bold("| || || | | || || _ | | _ || || || _ | \n") +
chalk.red.bold("| ___|| ___|| |_| || ___|| | || | |_| ||_ _|| _ || | || \n") +
chalk.red.bold("| | __ | |___ | || |___ | |_||_ | | | | | | | || |_||_ \n") +
chalk.red.bold("| || || ___|| _ || ___|| __ || | | | | |_| || __ |\n") +
chalk.red.bold("| |_| || |___ | | | || |___ | | | || _ | | | | || | | |\n") +
chalk.red.bold("|_______||_______||_| |__||_______||___| |_||__| |__| |___| |_______||___| |_|\n")
chalk.blue.bold("_______ _______ __ __ _______ _______ __ _ _______ __ _ _______ \n") +
chalk.blue.bold("| || || |_| || || || | | || || | | || | \n") +
chalk.blue.bold("| || _ || || _ || _ || |_| || ___|| |_| ||_ _| \n") +
chalk.blue.bold("| || | | || || |_| || | | || || |___ | | | | \n") +
chalk.blue.bold("| _|| |_| || || ___|| |_| || _ || ___|| _ | | | \n") +
chalk.blue.bold("| |_ | || ||_|| || | | || | | || |___ | | | | | | \n") +
chalk.blue.bold("|_______||_______||_| |_||___| |_______||_| |__||_______||_| |__| |___| \n") +
chalk.red.bold("_______ _______ __ _ _______ ______ _______ _______ _______ ______ \n") +
chalk.red.bold("| || || | | || || _ | | _ || || || _ | \n") +
chalk.red.bold("| ___|| ___|| |_| || ___|| | || | |_| ||_ _|| _ || | || \n") +
chalk.red.bold("| | __ | |___ | || |___ | |_||_ | | | | | | | || |_||_ \n") +
chalk.red.bold("| || || ___|| _ || ___|| __ || | | | | |_| || __ |\n") +
chalk.red.bold("| |_| || |___ | | | || |___ | | | || _ | | | | || | | |\n") +
chalk.red.bold("|_______||_______||_| |__||_______||___| |_||__| |__| |___| |_______||___| |_|\n")
));
this.log((
......@@ -45,35 +45,35 @@ module.exports = class extends Generator {
chalk.white("https://stable.visual-framework.dev/developing/#components")
));
var componentType = ['element', 'block', 'container', 'layout', 'utility'];
if (vfNamespace != 'vf-') {
var DepartmentType = [vfName, 'VF Global'];
var componentType = ["element", "block", "container", "layout", "utility"];
if (vfNamespace != "vf-") {
var DepartmentType = [vfName, "VF Global"];
} else {
var DepartmentType = [vfName];
}
var prompts = [{
type: 'list',
name: 'dept',
type: "list",
name: "dept",
required: true,
message: 'Who\'s the component for?',
message: "Who's the component for?",
choices: DepartmentType
}, {
type: 'list',
name: 'type',
type: "list",
name: "type",
required: true,
message: 'What type of component is this?',
message: "What type of component is this?",
choices: componentType
}, {
type: 'input',
name: 'componentName',
type: "input",
name: "componentName",
required: true,
message: 'What\'s the name of your component? (all lowercase, a hyphen instead of space, will be prefixed with your project\'s namespace.)',
description: 'Component name'
message: "What's the name of your component? (all lowercase, a hyphen instead of space, will be prefixed with your project's namespace.)",
description: "Component name"
}, {
type: 'confirm',
name: 'npm',
message: 'Will this be published to npm?',
type: "confirm",
name: "npm",
message: "Will this be published to npm?",
default: true
}];
......@@ -85,29 +85,29 @@ module.exports = class extends Generator {
writing() {
switch (this.props.dept) {
case vfName:
case vfName:
var namespace = vfNamespace;
break;
case "VF Global":
case "VF Global":
var namespace = "vf-";
break;
}
var patternType = this.props.type;
var totalPath = vfComponentPath + '/' + namespace + this.props.componentName + "/";
var totalPath = vfComponentPath + "/" + namespace + this.props.componentName + "/";
var fileName = namespace + this.props.componentName;
var outputFile = fileName + '.njk';
var outputFile = fileName + ".njk";
this.fs.copyTpl(
this.templatePath('_component.njk'),
this.templatePath("_component.njk"),
this.destinationPath(totalPath + outputFile),
{
componentName: fileName
}
);
var outputFile = fileName + '.scss';
var outputFile = fileName + ".scss";
this.fs.copyTpl(
this.templatePath('_component.scss'),
this.templatePath("_component.scss"),
this.destinationPath(totalPath + outputFile),
{
isNpmComponent: this.props.npm,
......@@ -115,18 +115,18 @@ module.exports = class extends Generator {
}
);
var outputFile = fileName + '.variables.scss';
var outputFile = fileName + ".variables.scss";
this.fs.copyTpl(
this.templatePath('_component.variables.scss'),
this.templatePath("_component.variables.scss"),
this.destinationPath(totalPath + outputFile),
{
componentName: fileName
}
);
var outputFile = fileName + '.js';
var outputFile = fileName + ".js";
this.fs.copyTpl(
this.templatePath('_component.js'),
this.templatePath("_component.js"),
this.destinationPath(totalPath + outputFile),
{
componentNameJs: camelize(fileName), // JS friendly name
......@@ -134,9 +134,9 @@ module.exports = class extends Generator {
}
);
var outputFile = fileName + '.react.js';
var outputFile = fileName + ".react.js";
this.fs.copyTpl(
this.templatePath('_component.react.js'),
this.templatePath("_component.react.js"),
this.destinationPath(totalPath + outputFile),
{
componentNameReact: camelize(fileName, true), // React JS friendly name
......@@ -144,9 +144,9 @@ module.exports = class extends Generator {
}
);
var outputFile = fileName + '.config.yml';
var outputFile = fileName + ".config.yml";
this.fs.copyTpl(
this.templatePath('_component.config.yml'),
this.templatePath("_component.config.yml"),
this.destinationPath(totalPath + outputFile),
{
componentType: patternType,
......@@ -155,24 +155,24 @@ module.exports = class extends Generator {
);
this.fs.copyTpl(
this.templatePath('_README.md'),
this.destinationPath(totalPath + 'README.md'),
this.templatePath("_README.md"),
this.destinationPath(totalPath + "README.md"),
{
componentName: fileName
}
);
this.fs.copyTpl(
this.templatePath('_.npmignore'),
this.destinationPath(totalPath + '.npmignore'),
this.templatePath("_.npmignore"),
this.destinationPath(totalPath + ".npmignore"),
{
componentName: fileName
}
);
this.fs.copyTpl(
this.templatePath('_CHANGELOG.md'),
this.destinationPath(totalPath + 'CHANGELOG.md'),
this.templatePath("_CHANGELOG.md"),
this.destinationPath(totalPath + "CHANGELOG.md"),
{
componentName: fileName
}
......@@ -180,20 +180,20 @@ module.exports = class extends Generator {
if (this.props.npm) {
this.fs.copyTpl(
this.templatePath('_package.json'),
this.destinationPath(totalPath + 'package.json'),
this.templatePath("_package.json"),
this.destinationPath(totalPath + "package.json"),
{
componentName: fileName,
componentHomepage: config.vfConfig.vfHomepage,
componentStylesheet: fileName + '.scss'
componentStylesheet: fileName + ".scss"
}
);
}
if (this.props.npm) {
this.fs.copyTpl(
this.templatePath('_index.scss'),
this.destinationPath(totalPath + 'index.scss'),
this.templatePath("_index.scss"),
this.destinationPath(totalPath + "index.scss"),
{
componentName: fileName
}
......
const { DateTime } = require('luxon');
const _ = require('lodash');
const Path = require('path');
const { DateTime } = require("luxon");
const _ = require("lodash");
const Path = require("path");
module.exports = function(config) {
......@@ -22,7 +22,7 @@ module.exports = function(config) {
// return 'ddd' + value;
// });
// Add any utiliuty filters
// Add any utility filters
config.addFilter("dateDisplay", (dateObj, format = "d LLL y") => {
return DateTime.fromJSDate(dateObj, {
zone: "utc"
......@@ -33,12 +33,12 @@ module.exports = function(config) {
// {{ 'string words' | camelize(true) }}
config.addFilter("camelize", (str, upperCaseFirst = false) => {
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
if (upperCaseFirst) {
if (upperCaseFirst) {
return word.toUpperCase();
} else {
return index === 0 ? word.toLowerCase() : word.toUpperCase();
}
}).replace(/\s+/g, '').replace('-', '');
}).replace(/\s+/g, "").replace("-", "");
});
// Split filter support
......
const path = require('path');
const pkg = require(path.join(process.cwd(), '../../components/vf-design-tokens/dist/json/vf-breakpoints.ios.json'));
const path = require("path");
const pkg = require(path.join(process.cwd(), "../../components/vf-design-tokens/dist/json/vf-breakpoints.ios.json"));
module.exports = pkg;
const path = require('path');
const pkg = require(path.join(process.cwd(), '../../components/vf-design-tokens/dist/json/vf-colors.ios.json'));
const path = require("path");
const pkg = require(path.join(process.cwd(), "../../components/vf-design-tokens/dist/json/vf-colors.ios.json"));
module.exports = pkg;
const path = require('path');
const pkg = require(path.join(process.cwd(), '../../components/vf-design-tokens/dist/json/vf-color__neutral.ios.json'));
const path = require("path");
const pkg = require(path.join(process.cwd(), "../../components/vf-design-tokens/dist/json/vf-color__neutral.ios.json"));
module.exports = pkg;
const path = require('path');
const pkg = require(path.join(process.cwd(), '../../components/vf-design-tokens/dist/json/vf-spacing.ios.json'));
const path = require("path");
const pkg = require(path.join(process.cwd(), "../../components/vf-design-tokens/dist/json/vf-spacing.ios.json"));
module.exports = pkg;
const path = require('path');
const pkg = require(path.join(process.cwd(), '../../components/vf-design-tokens/dist/json/vf-color__brand.ios.json'));
const path = require("path");
const pkg = require(path.join(process.cwd(), "../../components/vf-design-tokens/dist/json/vf-color__brand.ios.json"));
module.exports = pkg;
const path = require('path');
const pkg = require(path.join(process.cwd(), '../../components/vf-design-tokens/dist/json/vf-color__buttons.ios.json'));
const path = require("path");
const pkg = require(path.join(process.cwd(), "../../components/vf-design-tokens/dist/json/vf-color__buttons.ios.json"));
module.exports = pkg;
const path = require('path');
const pkg = require(path.join(process.cwd(), '../../components/vf-design-tokens/dist/json/vf-color__text.ios.json'));
const path = require("path");
const pkg = require(path.join(process.cwd(), "../../components/vf-design-tokens/dist/json/vf-color__text.ios.json"));
module.exports = pkg;
const path = require('path');
const pkg = require(path.join(process.cwd(), '../../components/vf-design-tokens/dist/json/vf-themes.ios.json'));
const path = require("path");
const pkg = require(path.join(process.cwd(), "../../components/vf-design-tokens/dist/json/vf-themes.ios.json"));
module.exports = pkg;
const path = require('path');
const pkg = require(path.join(process.cwd(), '../../components/vf-design-tokens/dist/json/vf-font--monospace.ios.json'));
const path = require("path");
const pkg = require(path.join(process.cwd(), "../../components/vf-design-tokens/dist/json/vf-font--monospace.ios.json"));
module.exports = pkg;
const path = require('path');
const pkg = require(path.join(process.cwd(), '../../components/vf-design-tokens/dist/json/vf-font--sans.ios.json'));
const path = require("path");
const pkg = require(path.join(process.cwd(), "../../components/vf-design-tokens/dist/json/vf-font--sans.ios.json"));
module.exports = pkg;
const path = require('path');
const pkg = require(path.join(process.cwd(), '../../components/vf-design-tokens/dist/json/vf-ui-colors.ios.json'));
const path = require("path");
const pkg = require(path.join(process.cwd(), "../../components/vf-design-tokens/dist/json/vf-ui-colors.ios.json"));
module.exports = pkg;
'use strict';
"use strict";
const fs = require('fs');
const path = require('path');
const fs = require("fs");
const path = require("path");
/**
* Expose vf-config as a JS module
......@@ -26,28 +26,28 @@ const path = require('path');
*/
// Load the vf-core package.json config
const config = JSON.parse(fs.readFileSync('./package.json'));
const config = JSON.parse(fs.readFileSync("./package.json"));
let vfCoreConfig;
if (config.name === '@visual-framework/vf-core') {
if (config.name === "@visual-framework/vf-core") {
// if being run from within the vf-core project, use the local package.json
vfCoreConfig = JSON.parse(fs.readFileSync('./package.json'));
vfCoreConfig = JSON.parse(fs.readFileSync("./package.json"));
} else {
// load vfCoreConfig from node_modules
vfCoreConfig = JSON.parse(fs.readFileSync(require.resolve('@visual-framework/vf-core/package.json')));
vfCoreConfig = JSON.parse(fs.readFileSync(require.resolve("@visual-framework/vf-core/package.json")));
}
config.vfConfig = config.vfConfig || [];
global.vfName = config.vfConfig.vfName || "Visual Framework 2.0";
global.vfNamespace = config.vfConfig.vfNamespace || "vf-";
global.vfComponentPath = config.vfConfig.vfComponentPath || path.resolve('.', 'components');
global.vfBuildDestination = config.vfConfig.vfBuildDestination || 'temp/build-files';
global.vfThemePath = config.vfConfig.vfThemePath || '@frctl/mandelbrot';
global.vfBuildFractalMode = config.vfConfig.vfBuildFractalMode || 'normal';
global.vfVersion = vfCoreConfig.version || 'not-specified';
const componentPath = path.resolve('.', global.vfComponentPath).replace(/\\/g, '/');
const componentDirectories = config.vfConfig.vfComponentDirectories || ['vf-core-components'];
const buildDestionation = path.resolve('.', global.vfBuildDestination).replace(/\\/g, '/');
global.vfComponentPath = config.vfConfig.vfComponentPath || path.resolve(".", "components");
global.vfBuildDestination = config.vfConfig.vfBuildDestination || "temp/build-files";
global.vfThemePath = config.vfConfig.vfThemePath || "@frctl/mandelbrot";
global.vfBuildFractalMode = config.vfConfig.vfBuildFractalMode || "normal";
global.vfVersion = vfCoreConfig.version || "not-specified";
const componentPath = path.resolve(".", global.vfComponentPath).replace(/\\/g, "/");
const componentDirectories = config.vfConfig.vfComponentDirectories || ["vf-core-components"];
const buildDestionation = path.resolve(".", global.vfBuildDestination).replace(/\\/g, "/");
module.exports = {
componentPath,
......
/*
Forked from: https://github.com/jergason/recursive-readdir
*/
var fs = require('fs')
var p = require('path')
var minimatch = require('minimatch')
var fs = require("fs");
var p = require("path");
var minimatch = require("minimatch");
function patternMatcher(pattern) {
return function(path, stats) {
var minimatcher = new minimatch.Minimatch(pattern, {matchBase: true})
return (!minimatcher.negate || stats.isFile()) && minimatcher.match(path)
}
var minimatcher = new minimatch.Minimatch(pattern, {matchBase: true});
return (!minimatcher.negate || stats.isFile()) && minimatcher.match(path);
};
}
function toMatcherFunction(ignoreEntry) {
if (typeof ignoreEntry == 'function') {
return ignoreEntry
if (typeof ignoreEntry == "function") {
return ignoreEntry;
} else {
return patternMatcher(ignoreEntry)
return patternMatcher(ignoreEntry);
}
}
function readdir(path, ignores, callback) {
if (typeof ignores == 'function') {
callback = ignores
ignores = []
if (typeof ignores == "function") {
callback = ignores;
ignores = [];
}
ignores = ignores.map(toMatcherFunction)
ignores = ignores.map(toMatcherFunction);
var list = []
var list = [];
fs.readdir(path, function(err, files) {
if (err) {
return callback(err)
return callback(err);
}
var pending = files.length
var pending = files.length;
if (!pending) {
// we are done, woop woop
return callback(null, list)
return callback(null, list);
}
files.forEach(function(file) {
var filePath = p.join(path, file)
var filePath = p.join(path, file);
fs.stat(filePath, function(_err, stats) {
if (_err) {
return callback(_err)
return callback(_err);
}
if (ignores.some(function(matcher) { return matcher(filePath, stats) })) {
pending -= 1
if (ignores.some(function(matcher) { return matcher(filePath, stats); })) {
pending -= 1;
if (!pending) {
return callback(null, list)
return callback(null, list);
}
return null
return null;
}
if (stats.isDirectory()) {
readdir(filePath, ignores, function(__err, res) {
if (__err) {
return callback(__err)
return callback(__err);
}