Skip to content

Commit

Permalink
feat: initial project setup based on whisk
Browse files Browse the repository at this point in the history
  • Loading branch information
Callin Mullaney committed Sep 9, 2024
1 parent a1d373a commit 1c64efd
Show file tree
Hide file tree
Showing 46 changed files with 765 additions and 2 deletions.
168 changes: 168 additions & 0 deletions .cli/init.js
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.load(fs.readFileSync(filePath, 'utf8'));
fs.writeFileSync(filePath, yaml.dump(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();
12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Emulsify Core version (see [releases](https://github.com/emulsify-ds/emulsify-core/releases)):
Emulsify Drupal version (see [releases](https://github.com/emulsify-ds/emulsify-drupal/releases)):

**What you did:**

**What happened:**

**Reproduction repository (if necessary):**

**Problem description:**

**Suggested solution:**
14 changes: 14 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
**This PR does the following:**
- Adds functionality bullet item
- Fixes this or that bullet item

### Related Issue(s)
- [Title of the issue](https://github.com/emulsify-ds/emulsify-drupal-starter/issues/1) (if applicable)

### Notes:
- (optional) Document any intentionally unfinished parts or known issues within this PR

### Functional Testing:
- [ ] Document steps that allow someone to fully test your code changes. Include screenshot and links when appropriate.


16 changes: 16 additions & 0 deletions .github/stale.yml
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
24 changes: 24 additions & 0 deletions .github/workflows/contributors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Add contributors
on:
schedule:
- cron: '20 20 * * *'
push:
branches:
- main
workflow_dispatch:

jobs:
add-contributors:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- 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'
23 changes: 23 additions & 0 deletions .github/workflows/semantic-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Release
on:
push:
branches: [main]
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install
run: npm install
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm run semantic-release
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scripts-prepend-node-path=true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
56 changes: 56 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Code of Conduct

## Our Pledge

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.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our community include:

- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
- Focusing on what is best not just for us as individuals, but for the overall community

Examples of unacceptable behavior include:

- The use of sexualized language or imagery, and sexual attention or
advances of any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

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.

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.

## Scope

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.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the project maintainers responsible for enforcement at [[email protected]](mailto:[email protected]). All complaints will be reviewed and investigated promptly and fairly.

All project maintainers are obligated to respect the privacy and security of the reporter of any incident.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
59 changes: 57 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,57 @@
# emulsify-drupal-starter
Starter repository for a Drupal platform install of Emulsify.
![Emulsify Design System](https://github.com/emulsify-ds/.github/blob/6bd435be881bd820bddfa05d88905efe29176a0a/assets/images/header.png)

# Emulsify Drupal Starter

**Emulsify Drupal Starter** is a scaffolding repository for the Emulsify CLI. It creates an installable Drupal theme.

## Documentation

[Emulsify CLI Usage](https://www.emulsify.info/docs/supporting-projects/emulsify-cli/emulsify-cli-usage)

### Installation

`emulsify init --platform drupal <name>`

**Note:** Installing a customized Emulsify Drupal theme requires the [Emulsify base theme](https://www.drupal.org/project/emulsify).


## Demo

1. [Storybook](http://storybook.emulsify.info/)

## Contributing

### [Code of Conduct](https://github.com/emulsify-ds/emulsify-drupal/blob/master/CODE_OF_CONDUCT.md)

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.

### Contribution Guide

Please also follow the issue template and pull request templates provided. See below for the correct places to post issues:

1. [Emulsify Starter](https://github.com/emulsify-ds/emulsify-drupal-starter/issues)

## Author

Emulsify&reg; is a product of [Four Kitchens &mdash; We make BIG websites](https://fourkitchens.com).

### Contributors

<table>
<tr>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">
<a href=https://github.com/amazingrando>
<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/>
<br />
<sub style="font-size:14px"><b>Randy Oest</b></sub>
</a>
</td>
<td align="center" style="word-wrap: break-word; width: 150.0; height: 150.0">
<a href=https://github.com/callinmullaney>
<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/>
<br />
<sub style="font-size:14px"><b>Callin Mullaney</b></sub>
</a>
</td>
</tr>
</table>
Empty file added assets/fonts/.gitkeep
Empty file.
Empty file added assets/icons/.gitkeep
Empty file.
6 changes: 6 additions & 0 deletions assets/icons/angle-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/icons/arrowRight.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 1c64efd

Please sign in to comment.