Skip to content

Commit

Permalink
no distributed dependencies (#40)
Browse files Browse the repository at this point in the history
* remove all dist dependencies

* remove lint

* add tests

* node 12.12

* build then test

* version for release
  • Loading branch information
raurir committed Feb 4, 2021
1 parent 952dbbb commit 9f8ec3b
Show file tree
Hide file tree
Showing 6 changed files with 2,498 additions and 2,332 deletions.
10 changes: 7 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"presets": ["env", "react"],
"plugins": ["transform-object-rest-spread", "babel-plugin-transform-runtime"]
}
"presets": [
["@babel/preset-env", {"useBuiltIns": false}]
],
"plugins": [
"@babel/plugin-transform-runtime"
]
}
11 changes: 5 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
defaults: &defaults
working_directory: ~/repo
docker:
- image: madecomfyau/node-aws:10
- image: madecomfyau/node-aws:12

jobs:
configure:
Expand All @@ -13,16 +13,16 @@ jobs:

- restore_cache:
keys:
- v1-yarn-cache-{{ checksum "yarn.lock" }}
- v2-yarn-cache-{{ checksum "yarn.lock" }}
# fallback to using the latest cache if no exact match is found
- v1-yarn-cache-
- v2-yarn-cache-

- run: yarn install

- save_cache:
paths:
- node_modules
key: v1-yarn-cache-{{ checksum "yarn.lock" }}
key: v2-yarn-cache-{{ checksum "yarn.lock" }}

- persist_to_workspace:
root: ~/repo
Expand All @@ -33,7 +33,6 @@ jobs:
steps:
- attach_workspace:
at: ~/repo
- run: yarn lint
- run: yarn test

build:
Expand Down Expand Up @@ -69,6 +68,7 @@ workflows:
- test:
requires:
- configure
- build
filters:
tags:
only: /^v[0-9].*/
Expand All @@ -81,7 +81,6 @@ workflows:
- deploy:
requires:
- test
- build
filters:
tags:
only: /^v[0-9].*/
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dist/
dist
.idea

coverage
.nyc*
docs/_book
gatsby-*
37 changes: 12 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "gatsby-plugin-asset-path",
"version": "3.0.2",
"version": "3.0.3",
"description": "Gatsby plugin that copies JS and CSS files and static folder to a custom folder",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir .",
"lint": "eslint src",
"test": "echo \"No test for now... yes we know.. it's baaaad\""
"test": "mocha",
"test:watch": "mocha --watch",
"test:html": "nyc --reporter=html mocha"
},
"author": "Ryan Chung <[email protected]>",
"license": "mit",
Expand All @@ -21,32 +22,18 @@
"subdirectory"
],
"dependencies": {
"fs-extra": "^7.0.0",
"history": "^4.7.2",
"react": "^16.4.2",
"react-router-dom": "^4.3.1"
"fs-extra": "^7.0.0"
},
"peerDependencies": {
"gatsby": ">2.4.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-eslint": "^10.0.2",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"eslint": "^5.4.0",
"eslint-config-madecomfy": "^1.0.1",
"eslint-config-prettier": "^3.0.1",
"eslint-plugin-cypress": "^2.0.1",
"eslint-plugin-graphql": "^2.1.1",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jest": "^21.21.0",
"eslint-plugin-node": "^7.0.1",
"eslint-plugin-prettier": "^2.6.2",
"eslint-plugin-promise": "^3.8.0",
"eslint-plugin-react": "^7.11.1",
"eslint-plugin-standard": "^3.1.0"
"@babel/cli": "^7.12.13",
"@babel/core": "^7.12.13",
"@babel/plugin-transform-runtime": "^7.12.13",
"@babel/preset-env": "^7.12.13",
"mocha": "^8.2.1",
"mock-fs": "^4.13.0",
"nyc": "^15.1.0"
}
}
76 changes: 76 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
const mock = require("mock-fs");
const assert = require("assert");
const fs = require("fs");

const {
onCreateWebpackConfig, // no need to test this.
onPostBuild,
} = require("./gatsby-node");

describe("onPostBuild", function () {
beforeEach(function () {
mock({
public: {
"script.js": "javascript",
"style.css": "css",
"image.png": "png",
static: {
"one.jpg": "jpeg",
"two.png": "png",
},
resources: {
"textfile.txt": "text",
},
},
});
});
afterEach(mock.restore);

after(mock.restore); // for nyc to run...

it("should copy files with path", function (done) {
onPostBuild({ pathPrefix: "/target/" }, {}).then(function () {
const files = fs.readdirSync("public/target");
const static = fs.readdirSync("public/target/static");
assert.deepEqual(files, ["script.js", "static", "style.css"]);
assert.deepEqual(static, ["one.jpg", "two.png"]);
done();
});
});

it("should copy files with domain", function (done) {
onPostBuild({ pathPrefix: "http://www.domain.com/target/" }, {}).then(
function () {
const files = fs.readdirSync("public/target");
const static = fs.readdirSync("public/target/static");
assert.deepEqual(files, ["script.js", "static", "style.css"]);
assert.deepEqual(static, ["one.jpg", "two.png"]);
done();
},
);
});

it("should copy specific fileTypes other than static files", function (done) {
onPostBuild({ pathPrefix: "/assets/" }, { fileTypes: ["css", "png"] }).then(
function () {
const files = fs.readdirSync("public/assets");
const static = fs.readdirSync("public/assets/static");
assert.deepEqual(files, ["image.png", "static", "style.css"]);
assert.deepEqual(static, ["one.jpg", "two.png"]);
done();
},
);
});

it("should copy specific paths", function (done) {
onPostBuild({ pathPrefix: "/assets/" }, { paths: ["resources"] }).then(
function () {
const files = fs.readdirSync("public/assets");
const resources = fs.readdirSync("public/assets/resources");
assert.deepEqual(files, ["resources", "script.js", "style.css"]);
assert.deepEqual(resources, ["textfile.txt"]);
done();
},
);
});
});
Loading

0 comments on commit 9f8ec3b

Please sign in to comment.