Skip to content

Commit

Permalink
Merge pull request #93 from healthgovau/hds-starterkit-version
Browse files Browse the repository at this point in the history
Hds starterkit version
  • Loading branch information
Benjen authored Mar 14, 2022
2 parents 1665cd9 + b4db28b commit d3407a3
Show file tree
Hide file tree
Showing 8 changed files with 24,452 additions and 10,787 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "airbnb",
"rules" : {
"no-console": "off"
}
}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,8 @@ The HDS uses [Gulp](https://gulpjs.com) to create compiled versions of the HDS C
```
npm run gulp
```
### HDS Starter Kit

setup.js is a file which is used to configure the HDS Starter kit.
It is used to create a base fiel structure for instant development.
More information about the HDS Starter kit can be found here: https://github.com/healthgovau/health-design-system-starter-kit
74 changes: 74 additions & 0 deletions bin/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#! /usr/bin/env node
// const path = require('path');
const fs = require('fs-extra');
const getDeps = require('get-dependencies');
const { getInstalledPathSync } = require('get-installed-path');

console.log('Creating Health Design System starter kit base.');

// Collect paths
const hds = getInstalledPathSync('@health.gov.au/health-design-system', { local: true });
const basePath = process.cwd();
const srcDir = `${hds}/source`;
const destDir = `${process.cwd()}/assets/hds`;

// Copy files to assets folder
try {
fs.copySync(srcDir, destDir, { overwrite: true });
console.log('■ Files copied to assets folder');
} catch (err) {
console.error(err);
}

// Check if assets/scss/main.scss exists, if not create it with reference.
if (!fs.existsSync(`${basePath}/assets/scss`)) {
fs.mkdirSync(`${basePath}/assets/scss`);
}
if (fs.existsSync(`${basePath}/assets/scss/main.scss`)) {
console.log('/assets/scss/main.scss exists, ensure that it contains:\n @import \'../hds/sass/all.scss\';\nto utilise HDS');
} else {
fs.writeFile(`${basePath}/assets/scss/main.scss`, '@import \'../hds/sass/all.scss\';', (err) => {
if (err) {
return console.log(err);
}
console.log('■ Created /assets/scss/main.scss and added import statement for HDS');
return true;
});
}

// Add GOLD dependencies

// Get dependencies for the Health Design System.
getDeps.getByFile(`${hds}/package.json`)
.then((result) => {
// Only process dependencies that starts with @gold and not includes the word pancake.
// Add correct path to the include statement.
const r = result.filter((val) => val.startsWith('@gold') && !val.includes('pancake'))
.map((filt) => `@import "${basePath}/node_modules/${filt}/lib/sass/_module.scss";`);

// Add comment to top of array.
r.unshift('\n//GOLD SCSS dependencies. ');

// Append dependencies to all.scss
fs.appendFile(`${process.cwd()}/assets/hds/sass/all.scss`, r.join('\n'), (err) => {
if (err) throw err;
console.log('■ GOLD references written to scss file.');
});
});

// Copy and rename pancake ref file
if (!fs.existsSync(`${basePath}/assets/hds/sass/vendors`)) {
fs.mkdirSync(`${basePath}/assets/hds/sass/vendors`);
}
if (fs.existsSync(`${basePath}/pancake/sass/pancake.scss`)) {
fs.copyFile(`${basePath}/pancake/sass/pancake.scss`, `${basePath}/assets/hds/sass/vendors/govau-ds.scss`, (err) => {
if (err) throw err;
console.log('■ Pancake reference file copied and renamed.');
});
} else {
console.log('\x1b[31m%s\x1b[0m', '■ WARNING! No pancace folder found, cannot copy file. Delete the node_modules folder and try again.');
}

// Remove pancake folder
fs.rmdirSync(`${basePath}/pancake`, { recursive: true });
console.log('■ Removed pancake folder');
Loading

0 comments on commit d3407a3

Please sign in to comment.