Skip to content

Commit

Permalink
First blood
Browse files Browse the repository at this point in the history
  • Loading branch information
gera2ld committed Sep 14, 2021
0 parents commit 57eb01b
Show file tree
Hide file tree
Showing 19 changed files with 451 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
extends: require.resolve('@gera2ld/plaid/config/babelrc-base'),
presets: [
],
};
1 change: 1 addition & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
defaults
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*
!/src
!/test
17 changes: 17 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
root: true,
extends: [
require.resolve('@gera2ld/plaid/eslint'),
require.resolve('@gera2ld/plaid-common-svelte/eslint'),
],
parserOptions: {
ecmaFeatures: {
legacyDecorators: true,
},
},
settings: {
'import/resolver': {
'babel-module': {},
},
},
};
29 changes: 29 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
branch:
- main

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Build
run: yarn && yarn build
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BASE_BRANCH: main
BRANCH: gh-pages
FOLDER: dist
SINGLE_COMMIT: true
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
*.log
*.lock
pnpm-lock.yaml
/.idea
/dist
/.nyc_output
/coverage
/types
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Gerald <gera2ld@live.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# calc

This is a calculator tool for specific domains.
59 changes: 59 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const gulp = require('gulp');
const log = require('fancy-log');
const rollup = require('rollup');
const del = require('del');

const DIST = 'dist';

function loadConfig() {
const rollupConfig = require('./rollup.conf');
return rollupConfig;
}

function clean() {
return del([DIST]);
}

function copy() {
return gulp.src('src/public/**')
.pipe(gulp.dest(DIST));
}

function buildJs() {
const rollupConfig = loadConfig();
return Promise.all(rollupConfig.map(async (config) => {
const bundle = await rollup.rollup(config);
await bundle.write(config.output);
}));
}

function watchJs() {
const rollupConfig = loadConfig();
const watcher = rollup.watch(rollupConfig);
watcher.on('event', e => {
if (e.code === 'ERROR') {
console.error();
console.error(`${e.error}`);
console.error();
} else if (e.code === 'BUNDLE_END') {
log(`Compilation success after ${e.duration}ms`);
}
});
}

function wrapError(handle) {
const wrapped = () => handle()
.catch(err => {
log(err.toString());
});
wrapped.displayName = handle.name;
return wrapped;
}

function watch() {
watchJs();
}

exports.clean = clean;
exports.build = gulp.series(copy, buildJs);
exports.dev = gulp.series(copy, watch);
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "calc",
"version": "0.0.0",
"description": "",
"author": "Gerald <gera2ld@live.com>",
"license": "MIT",
"private": true,
"scripts": {
"prepare": "husky install",
"dev": "gulp dev",
"clean": "gulp clean",
"build:js": "gulp build",
"prebuild": "run-s ci clean",
"build": "cross-env NODE_ENV=production run-s build:js",
"ci": "run-s lint",
"lint": "eslint --ext .js,.svelte ."
},
"dependencies": {
"@babel/runtime": "^7.15.3",
"core-js": "^3.16.3"
},
"devDependencies": {
"@gera2ld/plaid": "~2.4.0",
"@gera2ld/plaid-rollup": "~2.4.0",
"del": "^6.0.0",
"fancy-log": "^1.3.3",
"gulp": "^4.0.2",
"husky": "^7.0.2",
"rollup-plugin-browsersync": "^1.3.3",
"@gera2ld/plaid-common-svelte": "~2.2.0",
"rollup-plugin-svelte": "^7.1.0",
"svelte": "^3.42.3"
}
}
54 changes: 54 additions & 0 deletions rollup.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const { terser } = require('rollup-plugin-terser');
const {
defaultOptions,
getRollupPlugins,
isProd,
loadConfigSync,
} = require('@gera2ld/plaid');
const { browserSyncPlugin } = require('./scripts/browser-sync');
const { sveltePlugin } = require('./scripts/svelte');

const DIST = 'dist';
const FILENAME = 'app';

const postcssConfig = loadConfigSync('postcss') || require('@gera2ld/plaid/config/postcssrc');
const postcssOptions = {
...postcssConfig,
extract: true,
};

const rollupConfig = [
{
input: {
input: 'src/index.js',
plugins: [
sveltePlugin({ isProd }),
...getRollupPlugins({
esm: true,
extensions: defaultOptions.extensions,
postcss: postcssOptions,
}),
isProd && terser(),
!isProd && browserSyncPlugin({ dist: DIST }),
].filter(Boolean),
},
output: {
format: 'iife',
file: `${DIST}/${FILENAME}.js`,
},
},
];

rollupConfig.forEach((item) => {
item.output = {
indent: false,
// If set to false, circular dependencies and live bindings for external imports won't work
externalLiveBindings: false,
...item.output,
};
});

module.exports = rollupConfig.map(({ input, output }) => ({
...input,
output,
}));
13 changes: 13 additions & 0 deletions scripts/browser-sync.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const browserSync = require('rollup-plugin-browsersync');

function browserSyncPlugin({
dist,
}) {
return browserSync({
server: dist,
notify: false,
open: false,
});
}

exports.browserSyncPlugin = browserSyncPlugin;
16 changes: 16 additions & 0 deletions scripts/svelte.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const svelte = require('rollup-plugin-svelte');

function sveltePlugin({
isProd,
generate = 'dom',
}) {
return svelte({
emitCss: true,
compilerOptions: {
dev: !isProd,
generate,
},
});
}

exports.sveltePlugin = sveltePlugin;
Loading

0 comments on commit 57eb01b

Please sign in to comment.