Skip to content

Commit

Permalink
feat: #25 automate dependency package versions
Browse files Browse the repository at this point in the history
  • Loading branch information
blackfalcon authored and AuroDesignSystem committed Apr 1, 2020
1 parent 598f6c2 commit ee63b6a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
23 changes: 19 additions & 4 deletions bin/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ const chalk = require('chalk');
const path = require('path');
const paths = require('../util/paths');
const log = require('../util/log');
const versionData = {
'designTokens': `2.10.9`,
'wcss': '2.8.13',
'icons': '2.1.3',
'focusVisible': '5.0.2',
'webcomponentsjs': '2.4.3',
'litElement': '2.3.1'
};

const lowerKebabCase = str => str.toLowerCase().replace(' ', '-');
const upperCamelCase = str =>
Expand Down Expand Up @@ -77,7 +85,7 @@ const makeFolder = async dir => {
}
};

const formatTemplateFileContents = (content, { name }) => {
const formatTemplateFileContents = (data, content, { name }) => {
// name to lower-kebab-case (e.g. Text Input -> text-input)
const lowerKebabCaseName = lowerKebabCase(name);
// name to UpperCamelCase (e.g. text-input -> TextInput)
Expand All @@ -88,12 +96,19 @@ const formatTemplateFileContents = (content, { name }) => {
const userEmail = require('git-user-email');
// generate new year for copyright stamp
const newYear = new Date().getFullYear();

const replacements = [
{ regex: /\[name\]/g, value: lowerKebabCaseName },
{ regex: /\[Name\]/g, value: upperCamelCaseName },
{ regex: /\[author\]/g, value: userName },
{ regex: /\[author-email\]/g, value: userEmail },
{ regex: /\[year\]/g, value: newYear }
{ regex: /\[year\]/g, value: newYear },
{ regex: /\[designTokens\]/g, value: data.designTokens },
{ regex: /\[wcss\]/g, value: data.wcss },
{ regex: /\[icons\]/g, value: data.icons },
{ regex: /\[focusVisible\]/g, value: data.focusVisible },
{ regex: /\[webcomponentsjs\]/g, value: data.webcomponentsjs },
{ regex: /\[litElement\]/g, value: data.litElement }
];

// replace all instances of [name] and [Name] accordingly
Expand All @@ -115,6 +130,7 @@ const copyFile = async (sourcePath, targetPath, params, fileRenames = {}) => {
encoding: 'utf8',
});
const formattedTemplateFileContents = formatTemplateFileContents(
versionData,
templateFileContents,
params
);
Expand Down Expand Up @@ -165,8 +181,7 @@ const generateFromTemplate = async () => {
const latestVersion = require('latest-version');

// this test needs to be updates post first release of new '@alaskaairux/wc-generator'
const latestPublishedVersion = await latestVersion('@alaskaairux/ods-wc-generator');

const latestPublishedVersion = await latestVersion('@alaskaairux/wc-generator');
log(chalk.green(`\nPublished: v${latestPublishedVersion} | Installed: v${pjson.version}\n`))

const params = parseArgs();
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions template/package.temp
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@
"main": "index.js",
"license": "Apache-2.0",
"dependencies": {
"lit-element": "^2.1.0"
"lit-element": "^[litElement]"
},
"peerDependencies": {
"@alaskaairux/orion-design-tokens": "^2.7.0",
"@alaskaairux/orion-web-core-style-sheets": "^2.6.7",
"@alaskaairux/orion-icons": "^2.1.1",
"@webcomponents/webcomponentsjs": "^2.2.9",
"focus-visible": "^5.0.2"
"@alaskaairux/orion-design-tokens": "^[designTokens]",
"@alaskaairux/orion-web-core-style-sheets": "^[wcss]",
"@alaskaairux/orion-icons": "^[icons]",
"@webcomponents/webcomponentsjs": "^[webcomponentsjs]",
"focus-visible": "^[focusVisible]"
},
"devDependencies": {
"@alaskaairux/orion-design-tokens": "^2.7.0",
"@alaskaairux/orion-icons": "^2.1.1",
"@alaskaairux/orion-web-core-style-sheets": "^2.6.7",
"@alaskaairux/orion-design-tokens": "^[designTokens]",
"@alaskaairux/orion-icons": "^[icons]",
"@alaskaairux/orion-web-core-style-sheets": "^[wcss]",
"@commitlint/cli": "^8.3.5",
"@commitlint/config-conventional": "^8.3.4",
"@open-wc/testing": "^2.3.9",
Expand All @@ -57,7 +57,7 @@
"autoprefixer": "^9.6.0",
"concat": "^1.0.3",
"copyfiles": "^2.1.0",
"focus-visible": "^5.0.2",
"focus-visible": "^[focusVisible]",
"gulp": "^4.0.1",
"gulp-autoprefixer": "^7.0.1",
"gulp-postcss": "^8.0.0",
Expand Down

0 comments on commit ee63b6a

Please sign in to comment.