Remove postinstall and add icons cache; fixes #107

pull/122/head
Cory LaViska 2020-07-18 07:00:28 -04:00
rodzic 7efdc1313c
commit cfe70b8cfe
5 zmienionych plików z 19 dodań i 13 usunięć

1
.gitignore vendored
Wyświetl plik

@ -20,6 +20,7 @@ log.txt
*.sublime-workspace
.stencil/
.icons/
.idea/
.vscode/
.sass-cache/

Wyświetl plik

@ -1,4 +1,5 @@
.github
.icons
.stencil
dist
docs/assets

Wyświetl plik

@ -1,5 +1,9 @@
# Changelog
## 2.0.0-beta.5
- Removed unused dependency
## 2.0.0-beta.4
- Added `pill` variation to badges

Wyświetl plik

@ -14,16 +14,21 @@ let numIcons = 0;
(async () => {
try {
const version = require('./node_modules/bootstrap-icons/package.json').version;
const srcPath = `./temp/icons-${version}`;
const srcPath = `./.icons/icons-${version}`;
const url = `https://github.com/twbs/icons/archive/v${version}.zip`;
// Download the source from GitHub (since not everything is published to NPM)
console.log(chalk.cyan(`\nDownloading and extracting Bootstrap Icons ${version}... 📦\n`));
await del(['./src/components/icon/icons', './temp']);
await download(url, './temp', { extract: true });
try {
await fs.stat(`${srcPath}/LICENSE.md`);
console.log(chalk.cyan('Generating icons from cache... ♻️'));
} catch {
// Download the source from GitHub (since not everything is published to NPM)
console.log(chalk.cyan(`Downloading and extracting Bootstrap Icons ${version}... 📦`));
await download(url, './.icons', { extract: true });
}
// Copy icons
console.log(chalk.cyan(`Copying icons and license... 🚛\n`));
console.log(chalk.cyan(`Copying icons and license... 🚛`));
await del(['./src/components/icon/icons']);
await Promise.all([
copy(`${srcPath}/icons`, './src/components/icon/icons'),
copy(`${srcPath}/LICENSE.md`, './src/components/icon/icons/LICENSE.md'),
@ -31,7 +36,7 @@ let numIcons = 0;
]);
// Generate metadata
console.log(chalk.cyan(`Generating icon metadata... 🏷\n`));
console.log(chalk.cyan(`Generating icon metadata... 🏷`));
const files = await glob(`${srcPath}/docs/content/icons/**/*.md`);
const metadata = await Promise.map(files, async file => {
@ -49,10 +54,6 @@ let numIcons = 0;
await fs.writeFile('./src/components/icon/icons/icons.json', JSON.stringify(metadata, null, 2), 'utf8');
// More cleanup
console.log(chalk.cyan(`Cleaning up... 🧹\n`));
await del('./temp');
console.log(chalk.green(`Successfully processed ${numIcons} icons! ✨\n`));
} catch (err) {
console.error(err);

Wyświetl plik

@ -23,13 +23,12 @@
},
"scripts": {
"build": "stencil build --docs",
"dev": "stencil build --dev --docs --watch --serve --port 4001 --no-open",
"dev": "npm run make-icons && stencil build --dev --docs --watch --serve --port 4001 --no-open",
"lint": "eslint src/**/*{.ts,.tsx}",
"make-dist": "node make-dist.js",
"make-icons": "node make-icons.js",
"prettier": "npx prettier --write --loglevel warn .",
"postbuild": "npm run make-dist",
"postinstall": "npm run make-icons",
"prebuild": "npm run prettier && npm run lint && npm run make-icons",
"serve": "node dev-server.js",
"start": "concurrently --kill-others \"npm run dev\" \"npm run serve\"",