Skip to content

Commit b5c5a1d

Browse files
Merge pull request #2 from dreamsicle-io/feature/v2-exploration
Feature/v2 exploration
2 parents dfe4fe5 + 2275bac commit b5c5a1d

18 files changed

+1680
-409
lines changed

.editorconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# EditorConfig is awesome: https://EditorConfig.org
2-
31
root = true
42

53
[*]

.eslintrc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"env": {
3+
"node": true,
4+
"es6": true
5+
},
6+
"extends": [
7+
"eslint:recommended"
8+
],
9+
"parserOptions": {
10+
"ecmaVersion": 2020,
11+
"sourceType": "module"
12+
},
13+
"ignorePatterns": [
14+
".github/**/*",
15+
".vscode/**/*",
16+
"node_modules/**/*",
17+
"examples/**/*",
18+
"tests/**/*",
19+
"tmp/**/*",
20+
".editorconfig",
21+
".gitignore",
22+
".npmignore",
23+
".nvmrc",
24+
"package-lock.json",
25+
"README.md"
26+
],
27+
"rules": {
28+
"indent": ["error", "tab", { "SwitchCase": 1 }],
29+
"eol-last": ["error", "always"],
30+
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
31+
"no-console": ["error", { "allow": ["info", "warn", "error", "clear"] }]
32+
}
33+
}
34+
35+

.github/workflows/publish.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
publish:
10+
name: Publish
11+
runs-on: ubuntu-latest
12+
13+
# Initialize the env variables. These get set after the repo is checked out
14+
# because they depend on files in the repo.
15+
env:
16+
NODE_VERSION: ''
17+
18+
steps:
19+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it.
20+
- name: Checkout Repo
21+
id: checkout_repo
22+
uses: actions/checkout@v4
23+
24+
# Sets the environment variables from the env.sh script.
25+
- name: Set Environment Variables
26+
id: set_env_vars
27+
run: .github/workflows/scripts/env.sh
28+
29+
# Setup Node.
30+
- name: Setup Node
31+
id: setup_node
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: ${{ env.NODE_VERSION }}
35+
registry-url: 'https://registry.npmjs.org'
36+
37+
# Publish public package to NPM.
38+
- name: Publish
39+
id: publish
40+
run: npm publish --access public
41+
env:
42+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
13+
# Initialize the env variables. These get set after the repo is checked out
14+
# because they depend on files in the repo.
15+
env:
16+
MODULE_VERSION: ''
17+
18+
steps:
19+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it.
20+
- name: Checkout Repo
21+
id: checkout_repo
22+
uses: actions/checkout@v4
23+
24+
# Sets the environment variables from the env.sh script.
25+
- name: Set Environment Variables
26+
id: set_env_vars
27+
run: .github/workflows/scripts/env.sh
28+
29+
# Creates a release draft.
30+
- name: Create Release
31+
id: create_release
32+
uses: ncipollo/release-action@v1
33+
with:
34+
name: ${{ env.MODULE_VERSION }}
35+
tag: ${{ env.MODULE_VERSION }}
36+
commit: main
37+
draft: true
38+
prerelease: false
39+
token: ${{ secrets.GITHUB_TOKEN }}
40+
generateReleaseNotes: true
41+
skipIfReleaseExists: true

.github/workflows/scripts/env.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# This file must have permissions to run in a GitHub action.
4+
# To do this cross-env, use the following command from the project root:
5+
# git update-index --chmod=+x .github/workflows/scripts/env.sh
6+
7+
# Get the node version from the .nvmrc file.
8+
9+
NODE_VERSION=$(cat .nvmrc)
10+
11+
# Get the module version from the package.json file.
12+
13+
MODULE_VERSION=$(jq -r ".version" package.json)
14+
15+
# Set environment variables on $GITHUB_ENV.
16+
17+
echo "NODE_VERSION=$(echo $NODE_VERSION)" >> $GITHUB_ENV
18+
echo "MODULE_VERSION=$(echo $MODULE_VERSION)" >> $GITHUB_ENV

.github/workflows/test.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
test:
10+
name: Test
11+
runs-on: ubuntu-latest
12+
13+
# Initialize the env variables. These get set after the repo is checked out
14+
# because they depend on files in the repo.
15+
env:
16+
NODE_VERSION: ''
17+
18+
steps:
19+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it.
20+
- name: Checkout Repo
21+
id: checkout_repo
22+
uses: actions/checkout@v4
23+
24+
# Sets the environment variables from the env.sh script.
25+
- name: Set Environment Variables
26+
id: set_env_vars
27+
run: .github/workflows/scripts/env.sh
28+
29+
# Setup Node.
30+
- name: Setup Node
31+
id: setup_node
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: ${{ env.NODE_VERSION }}
35+
36+
# Installs npm and composer dependencies.
37+
- name: Install
38+
id: install
39+
run: npm ci
40+
41+
# Lint all files.
42+
- name: Lint
43+
id: lint
44+
run: npm run lint
45+
46+
# Runs a test component creation with the `verbose`
47+
# option to true for debugging.
48+
- name: Create Component
49+
id: create_component
50+
run: npm test TestComponent -- -v

.gitignore

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# Deps
2+
13
node_modules/
2-
examples/components/*
3-
!examples/components/_Template/
4+
5+
# Tests
6+
7+
tests/
8+
9+
# Temp
10+
11+
tmp/
12+
13+
# Logs
14+
15+
logs/

.npmignore

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
1+
# Config
2+
3+
.github/
4+
.vscode/
15
.editorconfig
6+
.eslintrc
27
.gitignore
38
.npmignore
4-
README.md
9+
.nvmrc
10+
11+
# Deps
12+
13+
node_modules/
14+
15+
# Tests
16+
517
examples/
18+
tests/
19+
20+
# Logs
21+
22+
logs/

.nvmrc

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

.vscode/extensions.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"recommendations": [
3+
"editorconfig.editorconfig",
4+
"dbaeumer.vscode-eslint",
5+
"github.vscode-github-actions"
6+
]
7+
}

.vscode/settings.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"[javascript][typescript][javascriptreact][typescriptreact]": {
3+
"editor.codeActionsOnSave": {
4+
"source.fixAll.eslint": "explicit"
5+
}
6+
},
7+
"files.insertFinalNewline": true,
8+
"files.eol": "\n",
9+
"eslint.validate": ["js", "jsx", "ts", "tsx", "mjs"],
10+
"eslint.enable": true,
11+
}

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ The scripts `name` arg can be passed through to the script when running it throu
5353
}
5454
```
5555

56+
> **Note:** If your templates live outside of the directory you want them to be created in, use the `-o` or `--outputPath` option to set the output path.
57+
5658
### 3. Run the scripts
5759

5860
Given the scripts created in step #2 above, run them as follows ― being sure to provide a component name after the script name. These commands will clone the `_Template` directory in each of the corresponding project directories and will perform replacements both on the file names themselves as well as on the text content within the files.
@@ -112,12 +114,17 @@ npx @dreamsicle.io/create-component --help
112114
**The above would ouput the following help information:**
113115

114116
```
115-
Usage: npx @dreamsicle.io/create-component [options] <name>
117+
Usage: npx @dreamsicle.io/create-component [options] <name>
118+
119+
Create a templated component structure.
116120
117-
Create a React component in the appropriate components directory.
121+
Arguments:
122+
name The name of the component
118123
119124
Options:
120-
-V, --version output the version number
121-
-p, --path <path> The relative path where the template to be used lives.
122-
-h, --help display help for command
125+
-V, --version output the version number
126+
-p, --path <path> The relative path where the template to be used lives
127+
-o, --outputPath [path] The relative path where the component should be placed, if different from the template path
128+
-v, --verbose Output extra information to the console (default: false)
129+
-h, --help display help for command
123130
```
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* This tests an unmodified file.
3+
*/
4+
function testUnmodified() {
5+
console.log('Hello from unmodified!');
6+
}

examples/components/_Template/utils/_Template.utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/**
32
* This is a test `_Template` util class file.
43
*
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* This tests a nested unmodified file.
3+
*/
4+
function testNestedUnmodified() {
5+
console.log('Hello from nested unmodified!');
6+
}

0 commit comments

Comments
 (0)