fix(create-freesewing-pattern) Breaking change in execa
This commit is contained in:
parent
2da9ba4c9e
commit
8964b18349
5 changed files with 95 additions and 94 deletions
|
@ -1,5 +1,8 @@
|
||||||
Unreleased:
|
Unreleased:
|
||||||
date:
|
date:
|
||||||
|
Fixed:
|
||||||
|
create-freesewing-pattern:
|
||||||
|
- Fixed breaking change in execa upgrade in 2.8.0
|
||||||
|
|
||||||
2.8.0:
|
2.8.0:
|
||||||
date: 2020-08-10
|
date: 2020-08-10
|
||||||
|
|
|
@ -94,10 +94,10 @@ ${strings[params.language]['cfp.runTheseCommands']}:
|
||||||
|
|
||||||
|
|
||||||
${strings[params.language]['cfp.devDocsAvailableAt']}
|
${strings[params.language]['cfp.devDocsAvailableAt']}
|
||||||
${chalk.bold('https://' + params.language + '.freesewing.dev/')}
|
${chalk.bold('https://freesewing.dev/')}
|
||||||
|
|
||||||
${strings[params.language]['cfp.talkToUs']}
|
${strings[params.language]['cfp.talkToUs']}
|
||||||
${chalk.bold('https://gitter.im/freesewing/freesewing')}
|
${chalk.bold('https://gitter.im/freesewing/development')}
|
||||||
|
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
|
|
@ -1,96 +1,94 @@
|
||||||
"use strict";
|
'use strict'
|
||||||
|
|
||||||
const handlebars = require("handlebars");
|
const handlebars = require('handlebars')
|
||||||
const execa = require("execa");
|
const execa = require('execa')
|
||||||
const fs = require("fs");
|
const fs = require('fs')
|
||||||
const globby = require("globby");
|
const globby = require('globby')
|
||||||
const mkdirp = require("make-dir");
|
const mkdirp = require('make-dir')
|
||||||
const ora = require("ora");
|
const ora = require('ora')
|
||||||
const path = require("path");
|
const path = require('path')
|
||||||
const pEachSeries = require("p-each-series");
|
const pEachSeries = require('p-each-series')
|
||||||
|
|
||||||
const pkg = require("../package");
|
const pkg = require('../package')
|
||||||
|
|
||||||
const templateBlacklist = new Set([
|
const templateBlacklist = new Set([path.join('example', 'public', 'favicon.ico')])
|
||||||
path.join("example", "public", "favicon.ico")
|
|
||||||
]);
|
|
||||||
|
|
||||||
module.exports = async info => {
|
module.exports = async (info) => {
|
||||||
const { manager, template, name, templatePath, git } = info;
|
const { manager, template, name, templatePath, git } = info
|
||||||
|
|
||||||
// handle scoped package names
|
// handle scoped package names
|
||||||
const parts = name.split("/");
|
const parts = name.split('/')
|
||||||
info.shortName = parts[parts.length - 1];
|
info.shortName = parts[parts.length - 1]
|
||||||
|
|
||||||
const dest = path.join(process.cwd(), info.shortName);
|
const dest = path.join(process.cwd(), info.shortName)
|
||||||
info.dest = dest;
|
info.dest = dest
|
||||||
await mkdirp(dest);
|
await mkdirp(dest)
|
||||||
|
|
||||||
const source =
|
const source =
|
||||||
template === "custom"
|
template === 'custom'
|
||||||
? path.join(process.cwd(), templatePath)
|
? path.join(process.cwd(), templatePath)
|
||||||
: path.join(__dirname, "..", "template", template);
|
: path.join(__dirname, '..', 'template', template)
|
||||||
const files = await globby(source, {
|
const files = await globby(source, {
|
||||||
dot: true
|
dot: true
|
||||||
});
|
})
|
||||||
|
|
||||||
{
|
{
|
||||||
const promise = pEachSeries(files, async file => {
|
const promise = pEachSeries(files, async (file) => {
|
||||||
return module.exports.copyTemplateFile({
|
return module.exports.copyTemplateFile({
|
||||||
file,
|
file,
|
||||||
source,
|
source,
|
||||||
dest,
|
dest,
|
||||||
info
|
info
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
ora.promise(promise, `Copying ${template} template to ${dest}`);
|
ora.promise(promise, `Copying ${template} template to ${dest}`)
|
||||||
await promise;
|
await promise
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const promise = module.exports.initPackageManager({ dest, info });
|
const promise = module.exports.initPackageManager({ dest, info })
|
||||||
ora.promise(promise, `Running ${manager} install and ${manager} link`);
|
ora.promise(promise, `Running ${manager} install and ${manager} link`)
|
||||||
await promise;
|
await promise
|
||||||
}
|
}
|
||||||
|
|
||||||
if (git) {
|
if (git) {
|
||||||
const promise = module.exports.initGitRepo({ dest });
|
const promise = module.exports.initGitRepo({ dest })
|
||||||
ora.promise(promise, "Initializing git repo");
|
ora.promise(promise, 'Initializing git repo')
|
||||||
await promise;
|
await promise
|
||||||
}
|
}
|
||||||
|
|
||||||
return dest;
|
return dest
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports.copyTemplateFile = async opts => {
|
module.exports.copyTemplateFile = async (opts) => {
|
||||||
const { file, source, dest, info } = opts;
|
const { file, source, dest, info } = opts
|
||||||
|
|
||||||
const fileRelativePath = path.relative(source, file);
|
const fileRelativePath = path.relative(source, file)
|
||||||
const destFilePath = path.join(dest, fileRelativePath);
|
const destFilePath = path.join(dest, fileRelativePath)
|
||||||
const destFileDir = path.parse(destFilePath).dir;
|
const destFileDir = path.parse(destFilePath).dir
|
||||||
|
|
||||||
await mkdirp(destFileDir);
|
await mkdirp(destFileDir)
|
||||||
|
|
||||||
if (templateBlacklist.has(fileRelativePath)) {
|
if (templateBlacklist.has(fileRelativePath)) {
|
||||||
const content = fs.readFileSync(file);
|
const content = fs.readFileSync(file)
|
||||||
fs.writeFileSync(destFilePath, content);
|
fs.writeFileSync(destFilePath, content)
|
||||||
} else {
|
} else {
|
||||||
const template = handlebars.compile(fs.readFileSync(file, "utf8"));
|
const template = handlebars.compile(fs.readFileSync(file, 'utf8'))
|
||||||
const content = template({
|
const content = template({
|
||||||
...info,
|
...info,
|
||||||
yarn: info.manager === "yarn"
|
yarn: info.manager === 'yarn'
|
||||||
});
|
})
|
||||||
|
|
||||||
fs.writeFileSync(destFilePath, content, "utf8");
|
fs.writeFileSync(destFilePath, content, 'utf8')
|
||||||
}
|
}
|
||||||
|
|
||||||
return fileRelativePath;
|
return fileRelativePath
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports.initPackageManager = async opts => {
|
module.exports.initPackageManager = async (opts) => {
|
||||||
const { dest, info } = opts;
|
const { dest, info } = opts
|
||||||
|
|
||||||
const example = path.join(dest, "example");
|
const example = path.join(dest, 'example')
|
||||||
|
|
||||||
const commands = [
|
const commands = [
|
||||||
{
|
{
|
||||||
|
@ -105,17 +103,17 @@ module.exports.initPackageManager = async opts => {
|
||||||
cmd: `${info.manager} install`,
|
cmd: `${info.manager} install`,
|
||||||
cwd: example
|
cwd: example
|
||||||
}
|
}
|
||||||
];
|
]
|
||||||
|
|
||||||
return pEachSeries(commands, async ({ cmd, cwd }) => {
|
return pEachSeries(commands, async ({ cmd, cwd }) => {
|
||||||
return execa.shell(cmd, { cwd });
|
return execa.sync(cmd, { cwd, shell: true })
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
module.exports.initGitRepo = async opts => {
|
module.exports.initGitRepo = async (opts) => {
|
||||||
const { dest } = opts;
|
const { dest } = opts
|
||||||
|
|
||||||
const gitIgnorePath = path.join(dest, ".gitignore");
|
const gitIgnorePath = path.join(dest, '.gitignore')
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
gitIgnorePath,
|
gitIgnorePath,
|
||||||
`
|
`
|
||||||
|
@ -141,11 +139,9 @@ npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
`,
|
`,
|
||||||
"utf8"
|
'utf8'
|
||||||
);
|
)
|
||||||
|
|
||||||
const cmd = `git init && git add . && git commit -m ":tada: Initialized ${
|
const cmd = `git init && git add . && git commit -m ":tada: Initialized ${pkg.name}@${pkg.version} with create-freesewing-pattern"`
|
||||||
pkg.name
|
return execa.sync(cmd, { cwd: dest, shell: true })
|
||||||
}@${pkg.version} with create-freesewing-pattern"`;
|
}
|
||||||
return execa.shell(cmd, { cwd: dest });
|
|
||||||
};
|
|
||||||
|
|
|
@ -40,8 +40,10 @@
|
||||||
"rollup-plugin-peer-deps-external": "^2.2.3",
|
"rollup-plugin-peer-deps-external": "^2.2.3",
|
||||||
"rollup-plugin-terser": "^6.1.0",
|
"rollup-plugin-terser": "^6.1.0",
|
||||||
"rollup-plugin-yaml": "^2.0.0",
|
"rollup-plugin-yaml": "^2.0.0",
|
||||||
|
"rollup-plugin-postcss": "^3.1.5",
|
||||||
"@rollup/plugin-babel": "^5.1.0",
|
"@rollup/plugin-babel": "^5.1.0",
|
||||||
"@rollup/plugin-commonjs": "^14.0.0",
|
"@rollup/plugin-commonjs": "^14.0.0",
|
||||||
|
"@rollup/plugin-url": "^5.0.1",
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
"@rollup/plugin-json": "^4.1.0",
|
||||||
"@rollup/plugin-node-resolve": "^8.4.0",
|
"@rollup/plugin-node-resolve": "^8.4.0",
|
||||||
"@material-ui/core": "^4.11.0",
|
"@material-ui/core": "^4.11.0",
|
||||||
|
|
|
@ -1,47 +1,47 @@
|
||||||
import babel from "rollup-plugin-babel";
|
import url from '@rollup/plugin-url'
|
||||||
import commonjs from "rollup-plugin-commonjs";
|
import babel from '@rollup/plugin-babel'
|
||||||
import external from "rollup-plugin-peer-deps-external";
|
import resolve from '@rollup/plugin-node-resolve'
|
||||||
import postcss from "rollup-plugin-postcss";
|
import commonjs from '@rollup/plugin-commonjs'
|
||||||
import json from "rollup-plugin-json";
|
import json from '@rollup/plugin-json'
|
||||||
import resolve from "rollup-plugin-node-resolve";
|
import { terser } from 'rollup-plugin-terser'
|
||||||
import url from "rollup-plugin-url";
|
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
|
||||||
import svgr from "@svgr/rollup";
|
import postcss from 'rollup-plugin-postcss'
|
||||||
import minify from "rollup-plugin-babel-minify";
|
import { name, version, description, author, license } from './package.json'
|
||||||
import { name, version, description, author, license } from "./package.json";
|
|
||||||
|
|
||||||
import pkg from "./package.json";
|
import pkg from './package.json'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
input: "src/index.js",
|
input: 'src/index.js',
|
||||||
output: [
|
output: [
|
||||||
{
|
{
|
||||||
file: pkg.main,
|
file: pkg.main,
|
||||||
format: "cjs",
|
format: 'cjs',
|
||||||
sourcemap: true
|
sourcemap: true,
|
||||||
|
exports: 'default'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
file: pkg.module,
|
file: pkg.module,
|
||||||
format: "es",
|
format: 'es',
|
||||||
sourcemap: true
|
sourcemap: true,
|
||||||
|
exports: 'default'
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
plugins: [
|
plugins: [
|
||||||
external(),
|
peerDepsExternal(),
|
||||||
postcss({
|
postcss({
|
||||||
modules: true
|
modules: true
|
||||||
}),
|
}),
|
||||||
url({ exclude: ["**/*.svg"] }),
|
url({ exclude: ['**/*.svg'] }),
|
||||||
svgr(),
|
|
||||||
babel({
|
babel({
|
||||||
exclude: "node_modules/**"
|
exclude: 'node_modules/**'
|
||||||
}),
|
}),
|
||||||
resolve({ browser: true }),
|
resolve({ browser: true }),
|
||||||
json(),
|
json(),
|
||||||
commonjs(),
|
commonjs(),
|
||||||
minify({
|
terser({
|
||||||
comments: false,
|
output: {
|
||||||
sourceMap: true,
|
preamble: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */`
|
||||||
banner: `/**\n * ${name} | v${version}\n * ${description}\n * (c) ${new Date().getFullYear()} ${author}\n * @license ${license}\n */`
|
}
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
};
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue