Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ templates/**/package-lock.json
/playwright/.cache/

# We generate this on publish
boilerplate
boilerplate/functions
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
export const GITHUB_ACTION_DEPLOY = `name: Deploy to Juno
name: Deploy to Juno

on:
workflow_dispatch:
push:
branches: [main]

jobs:
build:
publish:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
Expand All @@ -25,4 +25,4 @@ jobs:
with:
args: deploy
env:
JUNO_TOKEN: $\{{ secrets.JUNO_TOKEN }}`
JUNO_TOKEN: ${{ secrets.JUNO_TOKEN }}
7 changes: 3 additions & 4 deletions scripts/cli-to-boilerplate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ set -e
NPM_ROOT=$(npm root -g)
SRC="$NPM_ROOT/@junobuild/cli/templates/eject"

DEST="./boilerplate"
DEST_FUNCTIONS="$DEST/functions"
DEST="./boilerplate/functions"

if [ -d "$DEST" ]; then
rm -rf "$DEST"
fi

mkdir -p "$DEST_FUNCTIONS"
mkdir -p "$DEST"

cp -r "$SRC/"* "$DEST_FUNCTIONS/"
cp -r "$SRC/"* "$DEST/"

echo "✅ Boilerplate copied to $DEST"
10 changes: 6 additions & 4 deletions src/services/generate.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {writeFile} from 'node:fs/promises';
import {basename, join, parse} from 'node:path';
import ora from 'ora';
import {BOILERPLATE_PATH, JUNO_CDN_URL} from '../constants/constants';
import {GITHUB_ACTION_DEPLOY} from '../templates/github-actions';
import type {PopulateInput, ServerlessFunctions} from '../types/generator';
import {untarFile, type UntarOutputFile} from '../utils/compress.utils';
import {
copyFiles,
createFolders,
createParentFolders,
getLocalTemplatePath,
getRelativeTemplatePath
Expand Down Expand Up @@ -125,11 +125,13 @@ const populateFromLocal = async ({where, template, localDevelopment}: PopulateIn
};

const populateGitHubAction = async ({where}: PopulateInputFn) => {
const target = join(where ?? '', '.github', 'workflows', 'deploy.yaml');
const target = join(where ?? '', '.github', 'workflows');

createParentFolders(target);
createFolders(target);

await writeFile(target, GITHUB_ACTION_DEPLOY);
const source = join(BOILERPLATE_PATH, 'github');

await copyFiles({source, target});
};

const updatePackageJson = async ({
Expand Down
10 changes: 8 additions & 2 deletions src/utils/fs.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ export const getLocalTemplatePath = ({key}: {key: TemplateKey}) =>
export const createParentFolders = (target: string) => {
const folder = dirname(target);

if (!existsSync(folder)) {
mkdirSync(folder, {recursive: true});
createFolders(folder);
};

export const createFolders = (folder: string) => {
if (existsSync(folder)) {
return;
}

mkdirSync(folder, {recursive: true});
};

export const copyFiles = async ({source, target}: {source: string; target: string}) => {
Expand Down