Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 1 addition & 99 deletions files/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,99 +1 @@
name: CI

on:
push:
branches:
- main
- master
pull_request: {}

concurrency:
group: ci-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
lint:
name: "Lints"
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v4<% if (pnpm) { %>
- uses: pnpm/action-setup@v4<% } %>
- uses: actions/setup-node@v4
with:
node-version: 22
cache: <%= pnpm ? 'pnpm' : yarn ? 'yarn' : 'npm' %>
- name: Install Dependencies
run: <%= pnpm ? 'pnpm install --frozen-lockfile' : yarn ? 'yarn install --frozen-lockfile' : 'npm ci' %>
- name: Lint
run: <%= pnpm ? 'pnpm' : yarn ? 'yarn' : 'npm run' %> lint

test:
name: "Tests"
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

steps:
- uses: actions/checkout@v4<% if (pnpm) { %>
- uses: pnpm/action-setup@v4<% } %>
- uses: actions/setup-node@v4
with:
node-version: 22
cache: <%= pnpm ? 'pnpm' : yarn ? 'yarn' : 'npm' %>
- name: Install Dependencies
run: <%= pnpm ? 'pnpm install --frozen-lockfile' : yarn ? 'yarn install --frozen-lockfile' : 'npm ci' %>
- name: Run Tests
run: <%= pnpm ? 'pnpm' : yarn ? 'yarn' : 'npm run' %> test
# For the Try Scenarios
- id: set-matrix
run: |
<% if (pnpm) { %> echo "matrix=$(pnpm -s dlx @embroider/try list)" >> $GITHUB_OUTPUT<% } %>
<% if (npm) { %> echo "matrix=$(npx @embroider/try list)" >> $GITHUB_OUTPUT<% } %>

floating:
name: "Floating Dependencies"
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v4<% if (pnpm) { %>
- uses: pnpm/action-setup@v4<% } %>
- uses: actions/setup-node@v4
with:
node-version: 22
cache: <%= pnpm ? 'pnpm' : yarn ? 'yarn' : 'npm' %>
- name: Install Dependencies
run: <%= pnpm ? 'pnpm install --no-lockfile' : yarn ? 'yarn install --no-lockfile' : 'npm install --no-package-lock' %>
- name: Run Tests
run: <%= pnpm ? 'pnpm' : yarn ? 'yarn' : 'npm run' %> test

try-scenarios:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
needs: "test"
timeout-minutes: 10
strategy:
fail-fast: false
matrix: ${{fromJson(needs.test.outputs.matrix)}}

steps:
- uses: actions/checkout@v4<% if (pnpm) { %>
- uses: pnpm/action-setup@v4<% } %>
- uses: actions/setup-node@v4
with:
node-version: 22
cache: <%= pnpm ? 'pnpm' : yarn ? 'yarn' : 'npm' %>
- name: Apply Scenario
run: |
<% if (pnpm) { %> pnpm dlx @embroider/try apply ${{ matrix.name }}<% } %>
<% if (npm) { %> npx @embroider/try apply ${{ matrix.name }}<% } %>
- name: Install Dependencies
run: <%= pnpm ? 'pnpm install --no-lockfile' : yarn ? 'yarn install --no-lockfile' : 'npm install --no-package-lock' %>
- name: Run Tests
run: |
<% if (pnpm) { %>pnpm test<% } %>
<% if (npm) { %>npm test<% } %>
env: ${{ matrix.env }}
# Replaced from src/.github, based on selected packageManager
35 changes: 1 addition & 34 deletions files/.github/workflows/push-dist.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1 @@
# Because this library needs to be built,
# we can't easily point package.json files at the git repo for easy cross-repo testing.
#
# This workflow brings back that capability by placing the compiled assets on a "dist" branch
# (configurable via the "branch" option below)
name: Push dist

on:
push:
branches:
- main
- master

jobs:
push-dist:
name: Push dist
permissions:
contents: write
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v4<% if (pnpm) { %>
- uses: pnpm/action-setup@v4<% } %>
- uses: actions/setup-node@v4
with:
node-version: 22
cache: <%= pnpm ? 'pnpm' : yarn ? 'yarn' : 'npm' %>
- name: Install Dependencies
run: <%= pnpm ? 'pnpm install --frozen-lockfile' : yarn ? 'yarn install --frozen-lockfile' : 'npm ci' %>
- uses: kategengler/[email protected]
with:
branch: dist
token: ${{ secrets.GITHUB_TOKEN }}
# Replaced from src/.github, based on selected packageManager
20 changes: 17 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const { readFileSync } = require('fs');
const { join } = require('path');
const { sortPackageJson } = require('sort-package-json');

let date = new Date();
Expand All @@ -10,8 +12,20 @@ function stringifyAndNormalize(contents) {
return `${JSON.stringify(contents, null, 2)}\n`;
}

const workflows = join(__dirname, 'src/.github/workflows/');

const replacers = {
'package.json'(content) {
'.github/workflows/ci.yml'(templateVariables) {
let sourcePath = join(workflows, templateVariables.packageManager, 'ci.yml');

return readFileSync(sourcePath);
},
'.github/workflows/push-dist.yml'(templateVariables) {
let sourcePath = join(workflows, templateVariables.packageManager, 'push-dist.yml');

return readFileSync(sourcePath);
},
'package.json'(_templateVariables, content) {
return this.updatePackageJson(content);
},
};
Expand Down Expand Up @@ -93,11 +107,11 @@ module.exports = {
* _js_eslint.config.mjs is deleted
* _ts_eslint.config.mjs is renamed to eslint.config.mjs
*/
buildFileInfo(_intoDir, _templateVariables, file, _commandOptions) {
buildFileInfo(_intoDir, templateVariables, file, _commandOptions) {
let fileInfo = this._super.buildFileInfo.apply(this, arguments);

if (file in replacers) {
fileInfo.replacer = replacers[file].bind(this);
fileInfo.replacer = replacers[file].bind(this, templateVariables);
}

return fileInfo;
Expand Down
92 changes: 92 additions & 0 deletions src/.github/workflows/npm/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: CI

on:
push:
branches:
- main
- master
pull_request: {}

concurrency:
group: ci-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
lint:
name: "Lints"
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install Dependencies
run: npm ci
- name: Lint
run: npm run lint

test:
name: "Tests"
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install Dependencies
run: npm ci
- name: Run Tests
run: npm run test
# For the Try Scenarios
- id: set-matrix
run: |
echo "matrix=$(npx @embroider/try list)" >> $GITHUB_OUTPUT

floating:
name: "Floating Dependencies"
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install Dependencies
run: npm install --no-package-lock
- name: Run Tests
run: npm run test

try-scenarios:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
needs: "test"
timeout-minutes: 10
strategy:
fail-fast: false
matrix: ${{fromJson(needs.test.outputs.matrix)}}

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Apply Scenario
run: |
npx @embroider/try apply ${{ matrix.name }}
- name: Install Dependencies
run: npm install --no-package-lock
- name: Run Tests
run: |
npm test
env: ${{ matrix.env }}
33 changes: 33 additions & 0 deletions src/.github/workflows/npm/push-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Because this library needs to be built,
# we can't easily point package.json files at the git repo for easy cross-repo testing.
#
# This workflow brings back that capability by placing the compiled assets on a "dist" branch
# (configurable via the "branch" option below)
name: Push dist

on:
push:
branches:
- main
- master

jobs:
push-dist:
name: Push dist
permissions:
contents: write
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install Dependencies
run: npm ci
- uses: kategengler/[email protected]
with:
branch: dist
token: ${{ secrets.GITHUB_TOKEN }}
Loading