1
0
Fork 0

fix(create-freesewing-pattern): Fix for #257

This commit is contained in:
Joost De Cock 2020-01-25 16:07:37 +01:00
parent 3249901ded
commit a985eece5e
4 changed files with 120 additions and 65 deletions

View file

@ -1,9 +1,38 @@
Unreleased: Unreleased:
date: date: 2020-02-02
Added: Added:
breanna:
- Breanna is a body block for womenswear
core:
- Added the `Path.noop()` method
- Added the `Path.insop()` methods
i18n:
- Added translations for Breanna
Changed: Changed:
carlita:
- Renamed `highPointShoulderToBust` measurement to `hpsToBust`
components:
- DraftConfigurator has been updated to reflect frontend naming changes
- `pattern` is now `design`
- `recipe` is now `pattern`
- `gist` is now `data`
css-theme:
- Added new styles for the frontend changes in 2.2
i18n:
- Added/Updated strings for the 2.2 frontend changes
- Changed `Joost De Cock` to `Joost` because spam filters don't like cock
models:
- Extended the menswear size range to have 10 different sizes, just like womenswear
mui-theme:
- Changed the light background to `#f8f9fa` rather than `#fff`
- Changed the navbar to be light/dark based on the theme, rather than always dark
simone:
- Renamed `highPointShoulderToBust` measurement to `hpsToBust`
Deprecated: Deprecated:
Removed: Removed:
i18n:
- Removed the files for homepage translation, and moved that content to markdown
- Removed the files for editor translation, as it is no longer used
Fixed: Fixed:
Security: Security:

View file

@ -1,128 +1,147 @@
"use strict"; 'use strict'
const inquirer = require("inquirer"); const inquirer = require('inquirer')
const validateNpmName = require("validate-npm-package-name"); const validateNpmName = require('validate-npm-package-name')
const languages = require("@freesewing/i18n").languages; const languages = require('@freesewing/i18n').languages
const strings = require("@freesewing/i18n").strings; const strings = require('@freesewing/i18n').strings
const config = require("./config"); const config = require('./config')
const chalk = require('chalk')
let languageChoices = []; const stringToPackageName = string =>
string
.replace(/'|"|`|!|\*|~|\(|\)/g, '')
.replace(/ /g, '-')
.toLowerCase()
let languageChoices = []
for (let l of Object.keys(languages)) { for (let l of Object.keys(languages)) {
languageChoices.push({ languageChoices.push({
name: languages[l], name: languages[l],
value: l, value: l,
short: languages[l] short: languages[l]
}); })
} }
module.exports = async opts => { module.exports = async opts => {
if (opts.name && !validateNpmName(opts.name).validForNewPackages) { if (opts.name && !validateNpmName(opts.name).validForNewPackages) {
throw new Error(`invalid package name "${opts.name}"`); throw new Error(`invalid package name "${opts.name}"`)
} }
if (opts.skipPrompts) { if (opts.skipPrompts) {
if (!opts.name) { if (!opts.name) {
throw new Error( throw new Error('invalid input; you must pass a package name with --skip-prompts')
"invalid input; you must pass a package name with --skip-prompts"
);
} }
Object.keys(opts).forEach(key => { Object.keys(opts).forEach(key => {
const value = opts[key]; const value = opts[key]
if (typeof value === "function") { if (typeof value === 'function') {
opts[key] = value(opts); opts[key] = value(opts)
} }
}); })
return opts; return opts
} else { } else {
let lang = 'en'
const info = await inquirer.prompt([ const info = await inquirer.prompt([
{ {
type: "list", type: 'list',
name: "language", name: 'language',
message: "Language", message: 'Language',
choices: languageChoices, choices: languageChoices,
default: "en" default: 'en',
validate: language => {
lang = language
return true
}
}, },
{ {
type: "input", type: 'input',
name: "name", name: 'name',
message: info => strings[info.language]["cfp.patternName"], message: info => strings[lang]['cfp.patternName'],
validate: name => { validate: name => {
return name && validateNpmName(name).validForNewPackages; try {
if (name && validateNpmName(name).validForNewPackages) return true
else {
return (
strings[lang]['cfp.validNameWarning'] + ' ' + chalk.bold(stringToPackageName(name))
)
}
} catch (err) {
console.log({ err })
}
}, },
default: opts.name default: opts.name
}, },
{ {
type: "input", type: 'input',
name: "description", name: 'description',
message: info => strings[info.language]["cfp.patternDescription"], message: info => strings[info.language]['cfp.patternDescription'],
default: opts.description default: opts.description
}, },
{ {
type: "list", type: 'list',
name: "type", name: 'type',
message: info => strings[info.language]["cfp.patternType"], message: info => strings[info.language]['cfp.patternType'],
choices: info => [ choices: info => [
{ {
name: strings[info.language]["filter.type.pattern"], name: strings[info.language]['filter.type.pattern'],
value: "pattern" value: 'pattern'
}, },
{ name: strings[info.language]["filter.type.block"], value: "block" } { name: strings[info.language]['filter.type.block'], value: 'block' }
], ],
default: "pattern" default: 'pattern'
}, },
{ {
type: "list", type: 'list',
name: "department", name: 'department',
message: info => strings[info.language]["filter.department.title"], message: info => strings[info.language]['filter.department.title'],
choices: info => [ choices: info => [
{ {
name: strings[info.language]["filter.department.menswear"], name: strings[info.language]['filter.department.menswear'],
value: "menswear" value: 'menswear'
}, },
{ {
name: strings[info.language]["filter.department.womenswear"], name: strings[info.language]['filter.department.womenswear'],
value: "womenswear" value: 'womenswear'
}, },
{ {
name: strings[info.language]["filter.department.accessories"], name: strings[info.language]['filter.department.accessories'],
value: "accessories" value: 'accessories'
} }
], ],
default: "womenswear" default: 'womenswear'
}, },
{ {
type: "input", type: 'input',
name: "author", name: 'author',
message: info => strings[info.language]["cfp.author"], message: info => strings[info.language]['cfp.author'],
default: opts.author default: opts.author
}, },
{ {
type: "input", type: 'input',
name: "repo", name: 'repo',
message: info => strings[info.language]["cfp.githubRepo"], message: info => strings[info.language]['cfp.githubRepo'],
default: opts.repo default: opts.repo
}, },
{ {
type: "list", type: 'list',
name: "manager", name: 'manager',
message: info => strings[info.language]["cfp.packageManager"], message: info => strings[info.language]['cfp.packageManager'],
choices: ["npm", "yarn"], choices: ['npm', 'yarn'],
default: opts.manager default: opts.manager
} }
]); ])
config.set("author", info.author); config.set('author', info.author)
config.set("manager", info.manager); config.set('manager', info.manager)
config.set("template", "default"); config.set('template', 'default')
config.set("license", "MIT"); config.set('license', 'MIT')
info.template = "default"; info.template = 'default'
return { return {
...info, ...info,
git: opts.git, git: opts.git,
version: opts.version version: opts.version
}; }
} }
}; }

View file

@ -24,3 +24,4 @@ designModeIsOn: Design mode is on
designModeIsOff: Design mode is off designModeIsOff: Design mode is off
turnOn: Turn on turnOn: Turn on
turnOff: Turn off turnOff: Turn off
validNameWarning: "Please pick a different name as this name would cause problems.\nWe (re-)use the pattern name as the NPM package name.\nPackage names must be lowercase and cannot contain special characters.\nSo please name your pattern accordingly, like:"

View file

@ -1,12 +1,18 @@
acrossBack: Across back (deprecated) acrossBack: Across back (deprecated)
ankleCircumference: Ankle circumference ankleCircumference: Ankle circumference
bicepsCircumference: Biceps circumference bicepsCircumference: Biceps circumference
bustFront: Bust front
bustSpan: Bust span bustSpan: Bust span
centerBackNeckToHips: Centerback neck to hips
centerBackNeckToWaist: Centerback neck to waist centerBackNeckToWaist: Centerback neck to waist
chestCircumference: Chest circumference chestCircumference: Chest circumference
headCircumference: Head circumference headCircumference: Head circumference
highBust: High bust highBust: High bust
highPointShoulderToBust: High point shoulder to bust highBustFront: High bust front
hpsToBust: HPS to bust
hpsToHipsBack: HPS to hips back
hpsToHipsFront: HPS to hips front
hpsToWaistBack: HPS to waist back
hipsCircumference: Hips circumference hipsCircumference: Hips circumference
hipsToUpperLeg: Hips to upper leg hipsToUpperLeg: Hips to upper leg
inseam: Inseam inseam: Inseam