diff --git a/.prettierignore b/.prettierignore index f73b850..7e5a9e4 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,3 @@ dist templates -boilerplate \ No newline at end of file +boilerplate/functions \ No newline at end of file diff --git a/boilerplate/github/deploy.yml b/boilerplate/github/npm/deploy.yml similarity index 94% rename from boilerplate/github/deploy.yml rename to boilerplate/github/npm/deploy.yml index fe7013c..09f5c1a 100644 --- a/boilerplate/github/deploy.yml +++ b/boilerplate/github/npm/deploy.yml @@ -23,6 +23,6 @@ jobs: - name: Deploy to Juno uses: junobuild/juno-action@main with: - args: deploy + args: hosting deploy env: JUNO_TOKEN: ${{ secrets.JUNO_TOKEN }} diff --git a/boilerplate/github/publish.yml b/boilerplate/github/npm/publish.yml similarity index 81% rename from boilerplate/github/publish.yml rename to boilerplate/github/npm/publish.yml index 250f2de..99e9f53 100644 --- a/boilerplate/github/publish.yml +++ b/boilerplate/github/npm/publish.yml @@ -3,7 +3,7 @@ name: Publish Serverless Functions on: workflow_dispatch: release: - types: [ released ] + types: [released] jobs: publish: @@ -15,7 +15,7 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 24 - registry-url: "https://registry.npmjs.org" + registry-url: 'https://registry.npmjs.org' - name: Install Dependencies run: npm ci @@ -30,4 +30,4 @@ jobs: with: args: functions publish env: - JUNO_TOKEN: ${{ secrets.JUNO_TOKEN }} \ No newline at end of file + JUNO_TOKEN: ${{ secrets.JUNO_TOKEN }} diff --git a/boilerplate/github/pnpm/deploy.yml b/boilerplate/github/pnpm/deploy.yml new file mode 100644 index 0000000..aa0e174 --- /dev/null +++ b/boilerplate/github/pnpm/deploy.yml @@ -0,0 +1,32 @@ +name: Deploy to Juno + +on: + workflow_dispatch: + push: + branches: [main] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 24 + registry-url: 'https://registry.npmjs.org' + + - uses: pnpm/action-setup@v4 + with: + version: 10 + + - name: Install Dependencies + run: pnpm i --frozen-lockfile + + - name: Deploy to Juno + uses: junobuild/juno-action@main + with: + args: hosting deploy + env: + JUNO_TOKEN: ${{ secrets.JUNO_TOKEN }} diff --git a/boilerplate/github/pnpm/publish.yml b/boilerplate/github/pnpm/publish.yml new file mode 100644 index 0000000..6f78ba9 --- /dev/null +++ b/boilerplate/github/pnpm/publish.yml @@ -0,0 +1,37 @@ +name: Publish Serverless Functions + +on: + workflow_dispatch: + release: + types: [released] + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 24 + registry-url: 'https://registry.npmjs.org' + + - uses: pnpm/action-setup@v4 + with: + version: 10 + + - name: Install Dependencies + run: pnpm i --frozen-lockfile + + - name: Build + uses: junobuild/juno-action@full + with: + args: functions build + + - name: Publish + uses: junobuild/juno-action@full + with: + args: functions publish + env: + JUNO_TOKEN: ${{ secrets.JUNO_TOKEN }} diff --git a/boilerplate/github/yarn/deploy.yml b/boilerplate/github/yarn/deploy.yml new file mode 100644 index 0000000..39363f3 --- /dev/null +++ b/boilerplate/github/yarn/deploy.yml @@ -0,0 +1,34 @@ +name: Deploy to Juno + +on: + workflow_dispatch: + push: + branches: [main] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 24 + registry-url: 'https://registry.npmjs.org' + + - name: Enable Corepack + run: corepack enable + + - name: Activate Yarn + run: corepack prepare yarn@1.x --activate + + - name: Install Dependencies + run: yarn install --frozen-lockfile + + - name: Deploy to Juno + uses: junobuild/juno-action@main + with: + args: hosting deploy + env: + JUNO_TOKEN: ${{ secrets.JUNO_TOKEN }} diff --git a/boilerplate/github/yarn/publish.yml b/boilerplate/github/yarn/publish.yml new file mode 100644 index 0000000..a24bfb7 --- /dev/null +++ b/boilerplate/github/yarn/publish.yml @@ -0,0 +1,39 @@ +name: Publish Serverless Functions + +on: + workflow_dispatch: + release: + types: [released] + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 24 + registry-url: 'https://registry.npmjs.org' + + - name: Enable Corepack + run: corepack enable + + - name: Activate Yarn + run: corepack prepare yarn@1.x --activate + + - name: Install Dependencies + run: yarn install --frozen-lockfile + + - name: Build + uses: junobuild/juno-action@full + with: + args: functions build + + - name: Publish + uses: junobuild/juno-action@full + with: + args: functions publish + env: + JUNO_TOKEN: ${{ secrets.JUNO_TOKEN }} diff --git a/src/services/generate.services.ts b/src/services/generate.services.ts index b3a8110..830ff27 100644 --- a/src/services/generate.services.ts +++ b/src/services/generate.services.ts @@ -16,6 +16,7 @@ import { getLocalTemplatePath, getRelativeTemplatePath } from '../utils/fs.utils'; +import {whichPMRuns} from '../utils/pm.utils'; import {createDirectory, getLocalFiles, type LocalFileDescriptor} from '../utils/populate.utils'; export const generate = async ({gitHubAction, serverlessFunctions, ...rest}: PopulateInput) => { @@ -133,15 +134,14 @@ const populateGitHubAction = async ({ createFolders(target); - if (isNullish(serverlessFunctions)) { - const source = join(BOILERPLATE_PATH, 'github'); + const pm = whichPMRuns(); + const source = join(BOILERPLATE_PATH, 'github', pm); + if (isNullish(serverlessFunctions)) { await copyFile({source, target, file: 'deploy.yml'}); return; } - const source = join(BOILERPLATE_PATH, 'github'); - await copyFiles({source, target}); };