Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
✨ new(builder): Create package.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamleigh committed Nov 24, 2022
1 parent e33ba65 commit 4ccaf05
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/builder/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `@wpmudev/builder`

> TODO: description
## Usage

```
const builder = require('@wpmudev/builder');
// TODO: DEMONSTRATE API
```
7 changes: 7 additions & 0 deletions packages/builder/__tests__/builder.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

const builder = require('..');

describe('@wpmudev/builder', () => {
it('needs tests');
});
89 changes: 89 additions & 0 deletions packages/builder/lib/builder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/usr/bin/env node

/**
* Supported Packages
* List here all dependencies necessary to run required tasks.
*
* @since 0.0.0
*/
const path = require('path');
const gulp = require('gulp');
const rename = require('gulp-rename');
const sass = require('gulp-sass')(require('sass'));
const cleanCSS = require('gulp-clean-css');
const autoprefixer = require('gulp-autoprefixer');
const header = require('gulp-header');
const prettier = require('gulp-prettier');

/**
* Development Paths & Files
*
* @since 0.0.0
*/

const currentWorkingPath = process.cwd();
const { src, name } = require(path.join(currentWorkingPath, 'package.json'));

const inputPath = path.join(currentWorkingPath, src);
const packageName = name;
const fileName = name.replace('@wpmudev/', '');

/**
* WPMU DEV Banner
* Print this on SUI scripts.
*
* @since 0.0.0
*/
const banner = [
'/*!',
' * WPMU DEV Shared UI',
`${fileName !== 'sui-css' ? ' * CSS Framework (' + fileName + ')' : ''}`,
' * ',
' * Copyright 2018 - 2022 Incsub (https://incsub.com)',
' * Licensed under GPL-3.0 (http://www.gnu.org/licenses/gpl-3.0.html)',
' */',
'',
].join('\n');

/**
* List of Supported Browsers
*
* @since 0.0.0
*/
const browsersList = ['last 2 version', '> 1%'];

/**
* Compiling tasks.
* Compile files and copy to dist folder.
*
* @since 0.0.0
*/
function compile() {
return gulp
.src(inputPath)
.pipe(prettier())
.pipe(gulp.dest('src/'))
.pipe(sass({ outputStyle: 'expanded' }).on('error', sass.logError))
.pipe(autoprefixer(browsersList))
.pipe(header(banner))
.pipe(prettier())
.pipe(gulp.dest('dist/'))
.pipe(cleanCSS())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist/'))
.on('finish', function () {
console.log('📦 Package ' + packageName + ' compiled.');
});
}

/**
* Run tasks.
* Use Gulp to run compiling tasks.
*
* @since 0.0.0
*/
gulp.task('build', compile);

const build = gulp.task('build');

build();
57 changes: 57 additions & 0 deletions packages/builder/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"name": "@wpmudev/builder",
"version": "0.0.0",
"private": true,
"description": "This builder helps you compile SASS into CSS and minify it.",
"keywords": [
"incsub",
"wpmudev",
"shared-ui",
"css-builder"
],
"author": "WPMU DEV (https://wpmudev.com)",
"contributors": [
{
"name": "Leighton Sapir",
"email": "[email protected]",
"url": "https://iamleigh.com"
}
],
"license": "GPL-3.0",
"main": "lib/builder.js",
"directories": {
"lib": "lib",
"test": "__tests__"
},
"files": [
"lib"
],
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/wpmudev/sui-docs.git",
"directory": "packages/builder"
},
"bin": {
"css-builder": "./lib/builder.js"
},
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1"
},
"bugs": {
"url": "https://incsub.atlassian.net/browse/SUI"
},
"homepage": "https://github.com/wpmudev/sui-docs#readme",
"devDependencies": {
"gulp": "^4.0.2",
"gulp-autoprefixer": "^8.0.0",
"gulp-clean-css": "^4.3.0",
"gulp-header": "^2.0.9",
"gulp-prettier": "^4.0.0",
"gulp-rename": "^2.0.0",
"gulp-sass": "^5.1.0",
"sass": "^1.56.1"
}
}

0 comments on commit 4ccaf05

Please sign in to comment.