-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
451 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -701,3 +701,79 @@ jobs: | |
|
||
steps: | ||
- run: echo "Skipped" | ||
|
||
crwa: | ||
needs: check | ||
|
||
name: 🌲 Create Redwood App | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: ⬢ Enable Corepack | ||
run: corepack enable | ||
|
||
- name: ⬢ Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- name: 🐈 Set up yarn cache | ||
uses: ./.github/actions/set-up-yarn-cache | ||
|
||
- name: 🐈 Yarn install | ||
run: yarn install --inline-builds | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
|
||
- name: 🏗️ Build | ||
run: yarn build | ||
|
||
- name: Set up test project | ||
run: | | ||
yarn build:pack | ||
PROJECT_PATH=$(yarn set-up-test-project) | ||
echo "PROJECT_PATH=$PROJECT_PATH" >> $GITHUB_ENV | ||
working-directory: ./packages/create-redwood-app | ||
env: | ||
YARN_ENABLE_IMMUTABLE_INSTALLS: false | ||
|
||
- name: Set up git | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "Your Name" | ||
- name: e2e test | ||
run: yarn test e2e | ||
working-directory: ./packages/create-redwood-app | ||
env: | ||
PROJECT_PATH: ${{ env.PROJECT_PATH }} | ||
|
||
- name: Prompt tests | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install expect | ||
./tests/e2e_prompts.sh | ||
sleep 1 | ||
./tests/e2e_prompts_git.sh | ||
sleep 1 | ||
./tests/e2e_prompts_m.sh | ||
sleep 1 | ||
./tests/e2e_prompts_ts.sh | ||
sleep 1 | ||
./tests/e2e_prompts_overwrite.sh | ||
working-directory: ./packages/create-redwood-app | ||
env: | ||
PROJECT_PATH: ${{ env.PROJECT_PATH }} | ||
|
||
crwa-skip: | ||
needs: detect-changes | ||
if: needs.detect-changes.outputs.onlydocs == 'true' | ||
|
||
name: 🌲 Create Redwood App | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- run: echo "Skipped" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** @type {import('jest').Config} */ | ||
const config = { | ||
testMatch: ['<rootDir>/tests/*.test.mjs'], | ||
testPathIgnorePatterns: ['/node_modules/', '<rootDir>/templates/'], | ||
transform: {}, | ||
} | ||
|
||
module.exports = config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* eslint-env node */ | ||
|
||
import { fileURLToPath } from 'node:url' | ||
|
||
import Configstore from 'configstore' | ||
import { cd, fs, os, path, $ } from 'zx' | ||
|
||
const config = new Configstore('create-redwood-app') | ||
let projectPath = config.get('projectPath') | ||
|
||
const projectExists = projectPath && (await fs.pathExists(projectPath)) | ||
|
||
if (!projectExists) { | ||
const [timestamp] = new Date().toISOString().replace(/-|:/g, '_').split('.') | ||
|
||
projectPath = path.join(os.tmpdir(), `crwa_${timestamp}`) | ||
|
||
await fs.ensureDir(projectPath) | ||
await $`yarn --cwd ${projectPath} init -2` | ||
|
||
config.set('projectPath', projectPath) | ||
} | ||
|
||
const packagePath = fileURLToPath(new URL('../', import.meta.url)) | ||
const tarball = 'create-redwood-app.tgz' | ||
|
||
await fs.move( | ||
path.join(packagePath, tarball), | ||
path.join(projectPath, tarball), | ||
{ overwrite: true } | ||
) | ||
|
||
cd(projectPath) | ||
await $`yarn add ./${tarball}` | ||
|
||
console.log(projectPath) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
#!/usr/bin/env node | ||
/* eslint-env node */ | ||
|
||
import { cd, fs, $ } from 'zx' | ||
|
||
const projectPath = await fs.realpath(process.env.PROJECT_PATH) | ||
|
||
cd(projectPath) | ||
|
||
describe('crwa', () => { | ||
test('--help', async () => { | ||
const p = await $`yarn create-redwood-app --help` | ||
|
||
expect(p.exitCode).toEqual(0) | ||
expect(p.stdout).toMatchInlineSnapshot(` | ||
"------------------------------------------------------------------ | ||
🌲⚡️ Welcome to RedwoodJS! ⚡️🌲 | ||
------------------------------------------------------------------ | ||
Usage: create-redwood-app <project directory> [option] | ||
Options: | ||
--help Show help [boolean] | ||
--typescript, --ts Generate a TypeScript project. | ||
[boolean] [default: null] | ||
--overwrite Create even if target directory isn't empty | ||
[boolean] [default: false] | ||
--telemetry Enables sending telemetry events for this create | ||
command and all Redwood CLI commands | ||
https://telemetry.redwoodjs.com | ||
[boolean] [default: true] | ||
--git-init, --git Initialize a git repository. [boolean] [default: null] | ||
-m, --commit-message Commit message for the initial commit. | ||
[string] [default: null] | ||
-y, --yes Skip prompts and use defaults. | ||
[boolean] [default: null] | ||
--version Show version number [boolean] | ||
Examples: | ||
create-redwood-app newapp | ||
[?25l[?25h" | ||
`) | ||
expect(p.stderr).toMatchInlineSnapshot(`"[?25l[?25h"`) | ||
}) | ||
|
||
test('--version', async () => { | ||
const p = await $`yarn create-redwood-app --version` | ||
|
||
expect(p.exitCode).toEqual(0) | ||
expect(p.stdout).toMatchInlineSnapshot(` | ||
"------------------------------------------------------------------ | ||
🌲⚡️ Welcome to RedwoodJS! ⚡️🌲 | ||
------------------------------------------------------------------ | ||
6.0.7 | ||
[?25l[?25h" | ||
`) | ||
expect(p.stderr).toMatchInlineSnapshot(`"[?25l[?25h"`) | ||
}) | ||
|
||
test('--yes, -y', async () => { | ||
const p = await $`yarn create-redwood-app ./redwood-app --yes` | ||
|
||
// await $`yarn create-redwood-app redwood-app -y` | ||
// # `yarn pack` seems to ignore `.yarnrc.yml` | ||
// # cp "$SCRIPT_DIR/templates/ts/.yarnrc.yml" "$CRWA_ESM_TESTING_DIR" | ||
|
||
expect(p.exitCode).toEqual(0) | ||
expect(p.stdout).toMatchInlineSnapshot(` | ||
"------------------------------------------------------------------ | ||
🌲⚡️ Welcome to RedwoodJS! ⚡️🌲 | ||
------------------------------------------------------------------ | ||
[?25l⠋ Checking node and yarn compatibility | ||
[?25h[?25l✔ Compatibility checks passed | ||
[?25h✔ Creating your Redwood app in ./redwood-app based on command line argument | ||
✔ Using TypeScript based on command line flag | ||
✔ Will initialize a git repo based on command line flag | ||
[?25l⠋ Creating project files | ||
[?25h[?25l✔ Project files created | ||
[?25h[?25l⠋ Initializing a git repo | ||
[?25h[?25l✔ Initialized a git repo with commit message "Initial commit" | ||
[?25h | ||
Thanks for trying out Redwood! | ||
⚡️ Get up and running fast with this Quick Start guide: https://redwoodjs.com/quick-start | ||
Fire it up! 🚀 | ||
> cd redwood-app | ||
> yarn install | ||
> yarn rw dev | ||
[?25l✔ Initialized a git repo with commit message "Initial commit" | ||
[?25h" | ||
`) | ||
expect(p.stderr).toMatchInlineSnapshot(`"[?25l[?25h[?25l[?25h[?25l[?25h[?25l[?25h[?25l[?25h[?25l[?25h[?25l[?25h"`) | ||
|
||
await fs.rm('./redwood-app', { recursive: true, force: true }) | ||
}) | ||
|
||
test.failing('fails on unknown options', async () => { | ||
try { | ||
await $`yarn create-redwood-app --unknown-options`.timeout(2500) | ||
// Fail the test if the function didn't throw. | ||
expect(true).toEqual(false) | ||
} catch (p) { | ||
expect(p.exitCode).toEqual(1) | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/expect | ||
|
||
set projectPath $env(PROJECT_PATH) | ||
|
||
if {$projectPath eq ""} { | ||
puts "PROJECT_PATH is not set" | ||
exit | ||
} | ||
|
||
cd $projectPath | ||
|
||
set projectDirectory "redwood-app-prompt-test" | ||
|
||
spawn yarn create-redwood-app | ||
|
||
expect "Where would you like to create your Redwood app?" | ||
send "$projectDirectory\n" | ||
|
||
expect "Select your preferred language" | ||
# TypeScript | ||
send "\n" | ||
|
||
expect "Do you want to initialize a git repo?" | ||
# Yes | ||
send "\n" | ||
|
||
expect "Enter a commit message" | ||
send "first\n" | ||
|
||
expect eof | ||
catch wait result | ||
set exitStatus [lindex $result 3] | ||
|
||
if {$exitStatus == 0} { | ||
puts "Success" | ||
exec rm -rf $projectDirectory | ||
exit 0 | ||
} else { | ||
puts "Error: The process failed with exit status $exitStatus" | ||
exec rm -rf $projectDirectory | ||
exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/expect | ||
|
||
set projectPath $env(PROJECT_PATH) | ||
|
||
if {$projectPath eq ""} { | ||
puts "PROJECT_PATH is not set" | ||
exit | ||
} | ||
|
||
cd $projectPath | ||
|
||
set projectDirectory "redwood-app-prompt-git-test" | ||
|
||
spawn yarn create-redwood-app --git | ||
|
||
expect "Where would you like to create your Redwood app?" | ||
send "$projectDirectory\n" | ||
|
||
expect "Select your preferred language" | ||
# TypeScript | ||
send "\n" | ||
|
||
expect "Enter a commit message" | ||
send "first\n" | ||
|
||
expect eof | ||
catch wait result | ||
set exitStatus [lindex $result 3] | ||
|
||
if {$exitStatus == 0} { | ||
puts "Success" | ||
exec rm -rf $projectDirectory | ||
exit 0 | ||
} else { | ||
puts "Error: The process failed with exit status $exitStatus" | ||
exec rm -rf $projectDirectory | ||
exit 1 | ||
} |
Oops, something went wrong.