Skip to content

Commit 1c64efd

Browse files
author
Callin Mullaney
committed
feat: initial project setup based on whisk
1 parent a1d373a commit 1c64efd

46 files changed

Lines changed: 765 additions & 2 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cli/init.js

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
const yaml = require('js-yaml');
6+
7+
/**
8+
* Returns a boolean indicating whether or not the given object is a literal object.
9+
*
10+
* @param {any} obj object who's type will be checked.
11+
* @returns {boolean} boolean indicating whether or not the given obj is a literal object.
12+
*/
13+
const isObjectLiteral = (obj) =>
14+
obj != null && obj.constructor.name === 'Object';
15+
16+
/**
17+
* Attempts to require the project.emulsify.json file.
18+
*
19+
* @returns parsed project.emulsify.json file.
20+
*/
21+
const getEmulsifyConfig = () => {
22+
try {
23+
return require('../project.emulsify.json');
24+
} catch (e) {
25+
throw new Error(
26+
`Unable to load an Emulsify project config file (project.emulsify.json): ${String(
27+
e,
28+
)}`,
29+
);
30+
}
31+
};
32+
33+
/**
34+
* Throws if the given emulsify config file is invalid.
35+
*
36+
* @param {*} config emulsify project config, as loaded from a project.emulsify.json file.
37+
*/
38+
const validateEmulsifyConfig = (config) => {
39+
const prefix = 'Invalid project.emulsify.json config file';
40+
const example = JSON.stringify({
41+
project: {
42+
name: 'Example Project',
43+
machineName: 'example-project',
44+
},
45+
});
46+
47+
if (!config) {
48+
throw new Error(`${prefix}.`);
49+
}
50+
51+
if (!config.project || !isObjectLiteral(config.project)) {
52+
throw new Error(
53+
`${prefix}: Must contain a "project" key, with a name and machineName property. ${example}`,
54+
);
55+
}
56+
57+
if (typeof config.project.name !== 'string') {
58+
throw new Error(
59+
`${prefix}: the "project" object must contain a "name" key with a string value. ${example}`,
60+
);
61+
}
62+
63+
if (typeof config.project.machineName !== 'string') {
64+
throw new Error(
65+
`${prefix}: the "project" object must contain a "machineName" key with a string value. ${example}`,
66+
);
67+
}
68+
};
69+
70+
/**
71+
* Takes an array of objects describing the origin and destination of a given file,
72+
* then moves each specified file according to it's to/from properties.
73+
*
74+
* @param {Array<{ to: string, from: string }>} files array of objects depicting the origin and destination of a given file.
75+
* @returns void.
76+
*/
77+
const renameFiles = (files) =>
78+
files.map(({ from, to }) =>
79+
fs.renameSync(path.join(__dirname, from), path.join(__dirname, to)),
80+
);
81+
82+
/**
83+
* Takes a machineName, and returns a fn that, when called with a str,
84+
* replaces all instances of `emulsify` with the given machineName.
85+
*
86+
* @param {string} machineName string that should replace emulsify.
87+
* @returns {function} fn that when called with a str, replaces all instances of `emulsify` with the given machineName.
88+
*/
89+
const strReplaceEmulsify = (machineName) => (str) =>
90+
str.replace(/emulsify/g, machineName);
91+
92+
/**
93+
* Loads a yml file at filePath, applies the functor to the contents of the file, and writes it.
94+
*
95+
* @param {string} filePath path to the file that should be loaded, modified, and re-saved.
96+
* @param {fn} functor fn that should return the new contents of the file, to be saved.
97+
* @returns void.
98+
*/
99+
const applyToYmlFile = (filePath, functor) => {
100+
if (!filePath || typeof filePath !== `string`) {
101+
throw new Error(
102+
`Cannot modify a file without knowing how to access it: ${filePath}`,
103+
);
104+
}
105+
if (typeof functor !== 'function') {
106+
return;
107+
}
108+
109+
const file = yaml.load(fs.readFileSync(filePath, 'utf8'));
110+
fs.writeFileSync(filePath, yaml.dump(functor(file)));
111+
};
112+
113+
const main = () => {
114+
// Load up config file, throw if none exists.
115+
const config = getEmulsifyConfig();
116+
117+
// Validate config file, throw if it is missing
118+
//properties or is otherwise malformed.
119+
validateEmulsifyConfig(config);
120+
121+
const {
122+
project: { machineName, name },
123+
} = config;
124+
125+
// Move all files to their correct location.
126+
renameFiles([
127+
{
128+
from: '../emulsify.info.yml',
129+
to: `../${machineName}.info.yml`,
130+
},
131+
{
132+
from: '../emulsify.theme',
133+
to: `../${machineName}.theme`,
134+
},
135+
{
136+
from: '../emulsify.breakpoints.yml',
137+
to: `../${machineName}.breakpoints.yml`,
138+
},
139+
{
140+
from: '../emulsify.libraries.yml',
141+
to: `../${machineName}.libraries.yml`,
142+
},
143+
]);
144+
145+
// Update info.yml file.
146+
applyToYmlFile(
147+
path.join(__dirname, `../${machineName}.info.yml`),
148+
(info) => ({
149+
...info,
150+
name: machineName,
151+
libraries: info.libraries.map(strReplaceEmulsify(machineName)),
152+
}),
153+
);
154+
155+
// Update breakpoint.yml file.
156+
applyToYmlFile(
157+
path.join(__dirname, `../${machineName}.breakpoints.yml`),
158+
(breakpoints) => {
159+
const newBps = {};
160+
for (const prop of Object.keys(breakpoints)) {
161+
newBps[strReplaceEmulsify(machineName)(prop)] = breakpoints[prop];
162+
}
163+
return newBps;
164+
},
165+
);
166+
};
167+
168+
main();

.github/ISSUE_TEMPLATE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Emulsify Core version (see [releases](https://github.com/emulsify-ds/emulsify-core/releases)):
2+
Emulsify Drupal version (see [releases](https://github.com/emulsify-ds/emulsify-drupal/releases)):
3+
4+
**What you did:**
5+
6+
**What happened:**
7+
8+
**Reproduction repository (if necessary):**
9+
10+
**Problem description:**
11+
12+
**Suggested solution:**

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
**This PR does the following:**
2+
- Adds functionality bullet item
3+
- Fixes this or that bullet item
4+
5+
### Related Issue(s)
6+
- [Title of the issue](https://github.com/emulsify-ds/emulsify-drupal-starter/issues/1) (if applicable)
7+
8+
### Notes:
9+
- (optional) Document any intentionally unfinished parts or known issues within this PR
10+
11+
### Functional Testing:
12+
- [ ] Document steps that allow someone to fully test your code changes. Include screenshot and links when appropriate.
13+
14+

.github/stale.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Number of days of inactivity before an issue becomes stale
2+
daysUntilStale: 60
3+
# Number of days of inactivity before a stale issue is closed
4+
daysUntilClose: 7
5+
# Issues with these labels will never be considered stale
6+
exemptLabels:
7+
- 'Priority: Critical'
8+
# Label to use when marking an issue as stale
9+
staleLabel: 'Automatically Closed'
10+
# Comment to post when marking an issue as stale. Set to `false` to disable
11+
markComment: >
12+
This issue has been automatically marked as stale because it has not had
13+
recent activity. It will be closed if no further activity occurs. Thank you
14+
for your contributions.
15+
# Comment to post when closing a stale issue. Set to `false` to disable
16+
closeComment: false

.github/workflows/contributors.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Add contributors
2+
on:
3+
schedule:
4+
- cron: '20 20 * * *'
5+
push:
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
jobs:
11+
add-contributors:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: BobAnkh/add-contributors@master
16+
with:
17+
CONTRIBUTOR: '### Contributors'
18+
COLUMN_PER_ROW: '6'
19+
ACCESS_TOKEN: ${{secrets.ADD_TO_PROJECT_PAT}}
20+
IMG_WIDTH: '100'
21+
FONT_SIZE: '14'
22+
PATH: '/README.md'
23+
COMMIT_MESSAGE: 'docs(README): update contributors'
24+
AVATAR_SHAPE: 'round'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Release
2+
on:
3+
push:
4+
branches: [main]
5+
jobs:
6+
release:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v3
11+
with:
12+
fetch-depth: 0
13+
- name: Install Node.js
14+
uses: actions/setup-node@v3
15+
with:
16+
node-version: '20'
17+
- name: Install
18+
run: npm install
19+
- name: Release
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
23+
run: npm run semantic-release

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
scripts-prepend-node-path=true

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

CODE_OF_CONDUCT.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8+
9+
## Our Standards
10+
11+
Examples of behavior that contributes to a positive environment for our community include:
12+
13+
- Demonstrating empathy and kindness toward other people
14+
- Being respectful of differing opinions, viewpoints, and experiences
15+
- Giving and gracefully accepting constructive feedback
16+
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17+
- Focusing on what is best not just for us as individuals, but for the overall community
18+
19+
Examples of unacceptable behavior include:
20+
21+
- The use of sexualized language or imagery, and sexual attention or
22+
advances of any kind
23+
- Trolling, insulting or derogatory comments, and personal or political attacks
24+
- Public or private harassment
25+
- Publishing others' private information, such as a physical or email
26+
address, without their explicit permission
27+
- Other conduct which could reasonably be considered inappropriate in a
28+
professional setting
29+
30+
## Enforcement Responsibilities
31+
32+
Project maintainers are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33+
34+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35+
36+
## Scope
37+
38+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39+
40+
## Enforcement
41+
42+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the project maintainers responsible for enforcement at [howdy@fourkitchens.com](mailto:howdy@fourkitchens.com). All complaints will be reviewed and investigated promptly and fairly.
43+
44+
All project maintainers are obligated to respect the privacy and security of the reporter of any incident.
45+
46+
## Attribution
47+
48+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
49+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
50+
51+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
52+
53+
[homepage]: https://www.contributor-covenant.org
54+
55+
For answers to common questions about this code of conduct, see the FAQ at
56+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.

README.md

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,57 @@
1-
# emulsify-drupal-starter
2-
Starter repository for a Drupal platform install of Emulsify.
1+
![Emulsify Design System](https://github.com/emulsify-ds/.github/blob/6bd435be881bd820bddfa05d88905efe29176a0a/assets/images/header.png)
2+
3+
# Emulsify Drupal Starter
4+
5+
**Emulsify Drupal Starter** is a scaffolding repository for the Emulsify CLI. It creates an installable Drupal theme.
6+
7+
## Documentation
8+
9+
[Emulsify CLI Usage](https://www.emulsify.info/docs/supporting-projects/emulsify-cli/emulsify-cli-usage)
10+
11+
### Installation
12+
13+
`emulsify init --platform drupal <name>`
14+
15+
**Note:** Installing a customized Emulsify Drupal theme requires the [Emulsify base theme](https://www.drupal.org/project/emulsify).
16+
17+
18+
## Demo
19+
20+
1. [Storybook](http://storybook.emulsify.info/)
21+
22+
## Contributing
23+
24+
### [Code of Conduct](https://github.com/emulsify-ds/emulsify-drupal/blob/master/CODE_OF_CONDUCT.md)
25+
26+
The project maintainers have adopted a Code of Conduct that we expect project participants to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated.
27+
28+
### Contribution Guide
29+
30+
Please also follow the issue template and pull request templates provided. See below for the correct places to post issues:
31+
32+
1. [Emulsify Starter](https://github.com/emulsify-ds/emulsify-drupal-starter/issues)
33+
34+
## Author
35+
36+
Emulsify&reg; is a product of [Four Kitchens &mdash; We make BIG websites](https://fourkitchens.com).
37+
38+
### Contributors
39+
40+
<table>
41+
<tr>
42+
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">
43+
<a href=https://github.com/amazingrando>
44+
<img src=https://avatars.githubusercontent.com/u/409903?v=4 width="100;" style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Randy Oest/>
45+
<br />
46+
<sub style="font-size:14px"><b>Randy Oest</b></sub>
47+
</a>
48+
</td>
49+
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">
50+
<a href=https://github.com/callinmullaney>
51+
<img src=https://avatars.githubusercontent.com/u/369018?v=4 width="100;" style="border-radius:50%;align-items:center;justify-content:center;overflow:hidden;padding-top:10px" alt=Callin Mullaney/>
52+
<br />
53+
<sub style="font-size:14px"><b>Callin Mullaney</b></sub>
54+
</a>
55+
</td>
56+
</tr>
57+
</table>

0 commit comments

Comments
 (0)