Skip to content

Commit dd2a0f4

Browse files
authored
@gasket/resolve w/ CircleCI (godaddy#3)
* [api test] Prepare @gasket/resolve for OSS release. * [dist] Consistency * [dist] Add CircleCI config. * [dist fix] Learn the lerna. * [dist fix] Latest deps. * [dist] Moar deps.
1 parent 9c48b21 commit dd2a0f4

15 files changed

+559
-2
lines changed

.circleci/config.yaml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: 2
2+
3+
jobs:
4+
build:
5+
docker:
6+
# specify the version you desire here
7+
- image: circleci/node:10
8+
9+
working_directory: ~/repo
10+
11+
steps:
12+
- checkout
13+
14+
# Download and cache dependencies
15+
- restore_cache:
16+
keys:
17+
- v1-dependencies-{{ checksum "package.json" }}
18+
# fallback to using the latest cache if no exact match is found
19+
- v1-dependencies-
20+
21+
# Install lerna & bootstrap the mono-repo
22+
- run: npm install
23+
- run: lerna bootstrap
24+
25+
- save_cache:
26+
paths:
27+
- node_modules
28+
key: v1-dependencies-{{ checksum "package.json" }}
29+
30+
# Link the mono repo
31+
- run: lerna link
32+
33+
# Run tests!
34+
— run: npm test

package.json

+9-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@
44
"description": "Robust, pluggable, & render agnostic framework for rapid deliver modern web applications.",
55
"private": true,
66
"scripts": {
7-
"test": "echo \"Bespoke test runner for this mono-repo coming soon!\""
7+
"postinstall": "npm run bootstrap",
8+
"bootstrap": "lerna bootstrap --no-ci --hoist",
9+
"clean": "npm run clean:artifacts && npm run clean:packages && npm run clean:root",
10+
"clean:artifacts": "lerna run clean --parallel",
11+
"clean:packages": "lerna clean --yes",
12+
"clean:root": "rimraf node_modules",
13+
"test": "lerna run test --concurrency=1 --stream"
814
},
915
"repository": {
1016
"type": "git",
@@ -25,6 +31,7 @@
2531
},
2632
"homepage": "https://github.com/godaddy/gasket#readme",
2733
"devDependencies": {
28-
"lerna": "^3.15.0"
34+
"lerna": "^3.15.0",
35+
"rimraf": "^2.6.3"
2936
}
3037
}

packages/gasket-resolve/.eslintrc.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['godaddy', 'plugin:jest/recommended']
3+
};
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock.json binary

packages/gasket-resolve/.gitignore

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Logs (npm-debug.log, yarn-error.log, etc)
2+
logs
3+
*.log
4+
5+
# Runtime data
6+
pids
7+
*.pid
8+
*.seed
9+
*.pid.lock
10+
11+
# Directory for instrumented libs generated by jscoverage/JSCover
12+
lib-cov
13+
14+
# Coverage directory used by tools like istanbul
15+
coverage
16+
17+
# nyc test coverage
18+
.nyc_output
19+
20+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21+
.grunt
22+
23+
# Bower dependency directory (https://bower.io/)
24+
bower_components
25+
26+
# node-waf configuration
27+
.lock-wscript
28+
29+
# Compiled binary addons (http://nodejs.org/api/addons.html)
30+
build/Release
31+
32+
# Dependency directories
33+
node_modules/
34+
jspm_packages/
35+
36+
# Typescript v1 declaration files
37+
typings/
38+
39+
# Optional npm cache directory
40+
.npm
41+
42+
# OSX Finder cache files
43+
.DS_Store
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
60+
# Editor files
61+
.idea
62+
*.iml

packages/gasket-resolve/.npmignore

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Logs (npm-debug.log, yarn-error.log, etc)
2+
logs
3+
*.log
4+
5+
# Runtime data
6+
pids
7+
*.pid
8+
*.seed
9+
*.pid.lock
10+
11+
# Directory for instrumented libs generated by jscoverage/JSCover
12+
lib-cov
13+
14+
# Coverage directory used by tools like istanbul
15+
coverage
16+
17+
# nyc test coverage
18+
.nyc_output
19+
20+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21+
.grunt
22+
23+
# Bower dependency directory (https://bower.io/)
24+
bower_components
25+
26+
# node-waf configuration
27+
.lock-wscript
28+
29+
# Compiled binary addons (http://nodejs.org/api/addons.html)
30+
build/Release
31+
32+
# Dependency directories
33+
node_modules/
34+
jspm_packages/
35+
36+
# Typescript v1 declaration files
37+
typings/
38+
39+
# Optional npm cache directory
40+
.npm
41+
42+
# OSX Finder cache files
43+
.DS_Store
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
60+
# Editor files
61+
.idea
62+
*.iml
63+
64+
### ▲ .gitignore contents above
65+
### ▼ additional ignore files for publishing
66+
67+
test/*
68+
.eslintrc.js
69+
.gitattributes

packages/gasket-resolve/CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# `@gasket/resolve`
2+
3+
### 1.2.0
4+
5+
- Prepare for Open Source release.
6+
7+
### 1.1.0
8+
9+
- Add docs from `@gasket/plugin-engine`. Create `pluginInfoFor` API.
10+
11+
### 1.0.0
12+
13+
- Initial release.

packages/gasket-resolve/README.md

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# @gasket/resolve
2+
3+
Essential module resolution & configuration management for gasket plugins & presets.
4+
5+
## Usage
6+
7+
**@gasket/any-preset**
8+
``` js
9+
// index.js
10+
module.exports = require('@gasket/resolve/plugins')({
11+
dirname: __dirname,
12+
resolve: name => require(name)
13+
});
14+
```
15+
16+
## API Documentation
17+
18+
### `resolvePlugins({ dirname, resolve }`
19+
20+
``` js
21+
const { resolvePlugins } = require('@gasket/resolve');
22+
const resolvePlugins = require('@gasket/resolve/plugins');
23+
24+
console.log(resolvePlugins({
25+
dirname: __dirname,
26+
resolve: name => require(name)
27+
}))
28+
```
29+
30+
Responds with an Array of plugin information (i.e. a "preset").
31+
32+
### Preset data structure
33+
34+
The data structure generated for a preset is a combination of the
35+
`package.json` dependencies and the `preset.json` manifest file. For example,
36+
consider `@gasket/some-plugin` that is required by `@gasket/any-preset` as:
37+
38+
``` js
39+
"dependencies": {
40+
"@gasket/some-plugin": "^1.1.0"
41+
}
42+
```
43+
44+
with the following `preset.json`:
45+
46+
``` js
47+
{
48+
'some-plugin': {
49+
'arbitrary': 'default config values',
50+
'consumed': 'by the plugin',
51+
'these': 'can be overriden',
52+
'in your': 'gasket.config.js'
53+
}
54+
}
55+
```
56+
57+
This would get transformed into the following by `@gasket/resolve/plugins`:
58+
59+
``` js
60+
{
61+
required: module, // `require`d plugin material.
62+
from: '@gasket/default-preset', // Preset that included this plugin.
63+
range: '^1.1.0'// Semver range it was included at.
64+
shortName: 'some', // Convenient short name.
65+
name: '@gasket/some-plugin', // Full npm package name.
66+
config: { // Config read from preset.json.
67+
'arbitrary': 'default config values',
68+
'consumed': 'by the plugin',
69+
'these': 'can be overriden',
70+
'in your': 'gasket.config.js'
71+
}
72+
}
73+
```
74+
75+
### `new Resolver({ resolveFrom, resolve })`
76+
77+
Manages resolution operations for plugins and presets.
78+
79+
``` js
80+
const { Resolver } = require('@gasket/resolve');
81+
const Resolver = require('@gasket/resolve/resolve');
82+
83+
const resolver = new Resolver({
84+
resolveFrom: `${__dirname}/node_modules`,
85+
resolve: name => require(name)
86+
});
87+
88+
// Resolve a plugin
89+
resolver.pluginFor('short-name');
90+
91+
// Resolve a preset
92+
resolver.presetFor('short-name');
93+
```
94+
95+
##### LICENSE: [MIT](../../LICENSE)

packages/gasket-resolve/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
Resolver: require('./resolver'),
3+
plugins: require('./plugins')
4+
};

packages/gasket-resolve/package.json

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "@gasket/resolve",
3+
"version": "1.2.0",
4+
"description": "Essential module resolution & configuration management for gasket plugins & presets.",
5+
"main": "index.js",
6+
"scripts": {
7+
"lint": "eslint index.js test",
8+
"lint:fix": "npm run lint -- --fix",
9+
"posttest": "npm run lint",
10+
"test": "jest",
11+
"test:coverage": "jest --coverage"
12+
},
13+
"repository": {
14+
"type": "git",
15+
"url": "git+ssh://git@github.com/godaddy/gasket"
16+
},
17+
"keywords": [
18+
"gasket",
19+
"resolve",
20+
"preset",
21+
"plugin"
22+
],
23+
"author": "GoDaddy.com, LLC",
24+
"maintainers": [
25+
"Charlie Robbins <charlie.robbins@gmail.com>",
26+
"Jacob Page <jpage@godaddy.com>"
27+
],
28+
"license": "MIT",
29+
"dependencies": {
30+
"diagnostics": "^2.0.2"
31+
},
32+
"devDependencies": {
33+
"eslint": "^5.16.0",
34+
"eslint-config-godaddy": "^3.0.0",
35+
"eslint-plugin-jest": "^22.6.4",
36+
"eslint-plugin-json": "^1.4.0",
37+
"eslint-plugin-mocha": "^5.3.0",
38+
"jest": "^24.8.0"
39+
},
40+
"jest": {
41+
"testEnvironment": "node"
42+
},
43+
"homepage": "https://github.com/godaddy/gasket/tree/master/packages/gasket-resolve#readme",
44+
"bugs": {
45+
"url": "https://github.com/godaddy/gasket/issues"
46+
}
47+
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Returns the standard `PluginInfo` representation of the
3+
* given opts
4+
* @param {String} options.shortName e.g. 'core' for '@gasket/core-plugin'
5+
* @param {String} options.range Semver range required
6+
* @param {String} options.preset Preset that resolved this PluginInfo
7+
* @param {Object} options.required Result of plugin resolution (`module.exports`).
8+
* @return {PluginInfo} Standard plugin format for all gasket purposes.
9+
*/
10+
module.exports = function pluginInfoFor({ shortName, range, preset, required, config }) {
11+
return {
12+
required: required,
13+
kind: 'plugin',
14+
from: preset,
15+
shortName,
16+
name: `@gasket/${shortName}-plugin`,
17+
range,
18+
// TODO: Load an optional dirname/preset.json if it exists
19+
config: config || {}
20+
};
21+
};

0 commit comments

Comments
 (0)