-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6a2fbd4
Showing
241 changed files
with
63,920 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Browsers that we support | ||
|
||
last 1 version | ||
> 1% | ||
not dead | ||
ie 11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const yaml = require('js-yaml'); | ||
|
||
/** | ||
* Returns a boolean indicating whether or not the given object is a literal object. | ||
* | ||
* @param {any} obj object who's type will be checked. | ||
* @returns {boolean} boolean indicating whether or not the given obj is a literal object. | ||
*/ | ||
const isObjectLiteral = (obj) => | ||
obj != null && obj.constructor.name === 'Object'; | ||
|
||
/** | ||
* Attempts to require the project.emulsify.json file. | ||
* | ||
* @returns parsed project.emulsify.json file. | ||
*/ | ||
const getEmulsifyConfig = () => { | ||
try { | ||
return require('../project.emulsify.json'); | ||
} catch (e) { | ||
throw new Error( | ||
`Unable to load an Emulsify project config file (project.emulsify.json): ${String( | ||
e, | ||
)}`, | ||
); | ||
} | ||
}; | ||
|
||
/** | ||
* Throws if the given emulsify config file is invalid. | ||
* | ||
* @param {*} config emulsify project config, as loaded from a project.emulsify.json file. | ||
*/ | ||
const validateEmulsifyConfig = (config) => { | ||
const prefix = 'Invalid project.emulsify.json config file'; | ||
const example = JSON.stringify({ | ||
project: { | ||
name: 'Example Project', | ||
machineName: 'example-project', | ||
}, | ||
}); | ||
|
||
if (!config) { | ||
throw new Error(`${prefix}.`); | ||
} | ||
|
||
if (!config.project || !isObjectLiteral(config.project)) { | ||
throw new Error( | ||
`${prefix}: Must contain a "project" key, with a name and machineName property. ${example}`, | ||
); | ||
} | ||
|
||
if (typeof config.project.name !== 'string') { | ||
throw new Error( | ||
`${prefix}: the "project" object must contain a "name" key with a string value. ${example}`, | ||
); | ||
} | ||
|
||
if (typeof config.project.machineName !== 'string') { | ||
throw new Error( | ||
`${prefix}: the "project" object must contain a "machineName" key with a string value. ${example}`, | ||
); | ||
} | ||
}; | ||
|
||
/** | ||
* Takes an array of objects describing the origin and destination of a given file, | ||
* then moves each specified file according to it's to/from properties. | ||
* | ||
* @param {Array<{ to: string, from: string }>} files array of objects depicting the origin and destination of a given file. | ||
* @returns void. | ||
*/ | ||
const renameFiles = (files) => | ||
files.map(({ from, to }) => | ||
fs.renameSync(path.join(__dirname, from), path.join(__dirname, to)), | ||
); | ||
|
||
/** | ||
* Takes a machineName, and returns a fn that, when called with a str, | ||
* replaces all instances of `emulsify` with the given machineName. | ||
* | ||
* @param {string} machineName string that should replace emulsify. | ||
* @returns {function} fn that when called with a str, replaces all instances of `emulsify` with the given machineName. | ||
*/ | ||
const strReplaceEmulsify = (machineName) => (str) => | ||
str.replace(/emulsify/g, machineName); | ||
|
||
/** | ||
* Loads a yml file at filePath, applies the functor to the contents of the file, and writes it. | ||
* | ||
* @param {string} filePath path to the file that should be loaded, modified, and re-saved. | ||
* @param {fn} functor fn that should return the new contents of the file, to be saved. | ||
* @returns void. | ||
*/ | ||
const applyToYmlFile = (filePath, functor) => { | ||
if (!filePath || typeof filePath !== `string`) { | ||
throw new Error( | ||
`Cannot modify a file without knowing how to access it: ${filePath}`, | ||
); | ||
} | ||
if (typeof functor !== 'function') { | ||
return; | ||
} | ||
|
||
const file = yaml.safeLoad(fs.readFileSync(filePath, 'utf8')); | ||
fs.writeFileSync(filePath, yaml.safeDump(functor(file))); | ||
}; | ||
|
||
const main = () => { | ||
// Load up config file, throw if none exists. | ||
const config = getEmulsifyConfig(); | ||
|
||
// Validate config file, throw if it is missing | ||
//properties or is otherwise malformed. | ||
validateEmulsifyConfig(config); | ||
|
||
const { | ||
project: { machineName, name }, | ||
} = config; | ||
|
||
// Move all files to their correct location. | ||
renameFiles([ | ||
{ | ||
from: '../emulsify.info.yml', | ||
to: `../${machineName}.info.yml`, | ||
}, | ||
{ | ||
from: '../emulsify.theme', | ||
to: `../${machineName}.theme`, | ||
}, | ||
{ | ||
from: '../emulsify.breakpoints.yml', | ||
to: `../${machineName}.breakpoints.yml`, | ||
}, | ||
{ | ||
from: '../emulsify.libraries.yml', | ||
to: `../${machineName}.libraries.yml`, | ||
}, | ||
]); | ||
|
||
// Update info.yml file. | ||
applyToYmlFile( | ||
path.join(__dirname, `../${machineName}.info.yml`), | ||
(info) => ({ | ||
...info, | ||
name: machineName, | ||
libraries: info.libraries.map(strReplaceEmulsify(machineName)), | ||
}), | ||
); | ||
|
||
// Update breakpoint.yml file. | ||
applyToYmlFile( | ||
path.join(__dirname, `../${machineName}.breakpoints.yml`), | ||
(breakpoints) => { | ||
const newBps = {}; | ||
for (const prop of Object.keys(breakpoints)) { | ||
newBps[strReplaceEmulsify(machineName)(prop)] = breakpoints[prop]; | ||
} | ||
return newBps; | ||
}, | ||
); | ||
}; | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
**/*.min.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
root: true | ||
extends: | ||
- airbnb-base | ||
- plugin:security/recommended | ||
- plugin:prettier/recommended | ||
plugins: | ||
- security | ||
- prettier | ||
- jest | ||
env: | ||
es6: true | ||
browser: true | ||
jest/globals: true | ||
globals: | ||
expect: true | ||
it: true | ||
describe: true | ||
Drupal: true | ||
parser: "@babel/eslint-parser" | ||
parserOptions: | ||
requireConfigFile: false | ||
rules: | ||
strict: 0 | ||
import/no-extraneous-dependencies: 0 | ||
prettier/prettier: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
emulsify version (see [releases](https://github.com/emulsify-ds/emulsify-drupal/releases)): | ||
|
||
node version: | ||
|
||
npm (or yarn) version: | ||
|
||
**What you did:** | ||
|
||
**What happened:** | ||
|
||
**Reproduction repository (if necessary):** | ||
|
||
**Problem description:** | ||
|
||
**Suggested solution:** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
**What:** | ||
|
||
_brief description of change_ | ||
|
||
**Why:** | ||
|
||
_why this change improves emulsify_ | ||
|
||
**How:** | ||
|
||
_more details of changes made_ | ||
|
||
**To Test:** | ||
|
||
- [ ] Step 1 | ||
- [ ] Step 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Number of days of inactivity before an issue becomes stale | ||
daysUntilStale: 60 | ||
# Number of days of inactivity before a stale issue is closed | ||
daysUntilClose: 7 | ||
# Issues with these labels will never be considered stale | ||
exemptLabels: | ||
- 'Priority: Critical' | ||
# Label to use when marking an issue as stale | ||
staleLabel: 'Automatically Closed' | ||
# Comment to post when marking an issue as stale. Set to `false` to disable | ||
markComment: > | ||
This issue has been automatically marked as stale because it has not had | ||
recent activity. It will be closed if no further activity occurs. Thank you | ||
for your contributions. | ||
# Comment to post when closing a stale issue. Set to `false` to disable | ||
closeComment: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Add to projects | ||
|
||
on: | ||
issues: | ||
types: | ||
- opened | ||
pull_request: | ||
types: | ||
- opened | ||
|
||
jobs: | ||
add-to-project: | ||
name: Add issue to project | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/[email protected] | ||
with: | ||
# You can target a repository in a different organization | ||
# to the issue | ||
project-url: https://github.com/orgs/emulsify-ds/projects/6 | ||
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Add contributors | ||
on: | ||
schedule: | ||
- cron: "20 20 * * *" | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
add-contributors: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: BobAnkh/add-contributors@master | ||
with: | ||
CONTRIBUTOR: "### Contributors" | ||
COLUMN_PER_ROW: "6" | ||
ACCESS_TOKEN: ${{secrets.ADD_TO_PROJECT_PAT}} | ||
IMG_WIDTH: "100" | ||
FONT_SIZE: "14" | ||
PATH: "/README.md" | ||
COMMIT_MESSAGE: "docs(README): update contributors" | ||
AVATAR_SHAPE: "round" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Sync Drupal Dev Branch | ||
on: | ||
push: | ||
branches: | ||
- '*.x' | ||
jobs: | ||
sync: | ||
name: Sync Dev Branch | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Extract branch name | ||
shell: bash | ||
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" | ||
id: extract_branch | ||
- name: Add remote SSH Key | ||
uses: shimataro/ssh-key-action@v2 | ||
with: | ||
key: ${{ secrets.DRUPAL_ORG_SSH_KEY }} | ||
config: ${{ secrets.SSH_CONFIG }} | ||
known_hosts: ${{ secrets.KNOWN_HOSTS }} | ||
- name: Sync dev branch to Drupal.org Project | ||
run: | | ||
git remote add drupal-org '${{ secrets.DRUPAL_REPO_URL }}' | ||
git push drupal-org ${{ steps.extract_branch.outputs.branch }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Semantic Release on Merge | ||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
- 'alpha' | ||
- 'beta' | ||
jobs: | ||
release: | ||
name: Attempt Semantic Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Semantic Release | ||
id: semantic | ||
uses: cycjimmy/semantic-release-action@v2 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Add remote SSH Key | ||
uses: shimataro/ssh-key-action@v2 | ||
with: | ||
key: ${{ secrets.DRUPAL_ORG_SSH_KEY }} | ||
config: ${{ secrets.SSH_CONFIG }} | ||
known_hosts: ${{ secrets.KNOWN_HOSTS }} | ||
- name: Sync release tags to Drupal.org Project | ||
if: steps.semantic.outputs.new_release_published == 'true' | ||
run: | | ||
git remote add drupal-org '${{ secrets.DRUPAL_REPO_URL }}' | ||
git push drupal-org --tags | ||
git checkout master | ||
git push drupal-org master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Ignore compiled files. | ||
dist | ||
|
||
# Yarn/NPM | ||
node_modules | ||
|
||
# Storybook | ||
.out | ||
|
||
# System | ||
.DS_Store | ||
.idea | ||
.vscode | ||
|
||
# Git deploy | ||
.publish | ||
|
||
# Composer | ||
composer.lock | ||
vendor | ||
|
||
# Jest | ||
.coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm run lint-staged ; npm run lint |
Oops, something went wrong.