create-harper 1.12.12 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -6
- package/lib/constants/helpMessage.js +3 -0
- package/lib/fs/copyFile.js +31 -15
- package/lib/pkg/toComponentName.js +20 -0
- package/lib/steps/installAndOptionallyStart.js +15 -0
- package/lib/steps/scaffoldProject.js +4 -0
- package/package.json +1 -1
- package/template-nextjs/README.md +65 -17
- package/template-nextjs/_github/workflows/deploy.yaml +99 -41
- package/template-nextjs/package.json +2 -1
- package/template-nextjs-ts/README.md +65 -17
- package/template-nextjs-ts/_github/workflows/deploy.yaml +99 -41
- package/template-nextjs-ts/package.json +2 -1
- package/template-react/README.md +57 -25
- package/template-react/_github/workflows/deploy.yaml +90 -39
- package/template-react/package.json +2 -2
- package/template-react-ssr/README.md +57 -25
- package/template-react-ssr/_github/workflows/deploy.yaml +90 -39
- package/template-react-ssr/package.json +2 -2
- package/template-react-ts/README.md +57 -25
- package/template-react-ts/_github/workflows/deploy.yaml +90 -39
- package/template-react-ts/package.json +2 -2
- package/template-react-ts-ssr/README.md +57 -25
- package/template-react-ts-ssr/_github/workflows/deploy.yaml +90 -39
- package/template-react-ts-ssr/package.json +2 -2
- package/template-vanilla/README.md +57 -25
- package/template-vanilla/_github/workflows/deploy.yaml +90 -39
- package/template-vanilla/package.json +5 -3
- package/template-vanilla-ts/README.md +57 -25
- package/template-vanilla-ts/_github/workflows/deploy.yaml +90 -39
- package/template-vanilla-ts/package.json +5 -3
- package/template-vue/README.md +57 -25
- package/template-vue/_github/workflows/deploy.yaml +90 -39
- package/template-vue/package.json +2 -2
- package/template-vue-ssr/README.md +57 -25
- package/template-vue-ssr/_github/workflows/deploy.yaml +90 -39
- package/template-vue-ssr/package.json +2 -2
- package/template-vue-ts/README.md +57 -25
- package/template-vue-ts/_github/workflows/deploy.yaml +90 -39
- package/template-vue-ts/package.json +2 -2
- package/template-vue-ts-ssr/README.md +57 -25
- package/template-vue-ts-ssr/_github/workflows/deploy.yaml +90 -39
- package/template-vue-ts-ssr/package.json +2 -2
|
@@ -1,47 +1,34 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
# moved tag), authenticating a private clone with the encrypted token you sealed once via
|
|
7
|
-
# `your-package-manager-run-here deploy:setup`. The credential lives on the cluster, so this
|
|
8
|
-
# workflow handles no token.
|
|
9
|
-
#
|
|
10
|
-
# Required repository secrets (Settings → Secrets and variables → Actions):
|
|
11
|
-
# HARPER_CLI_TARGET your cluster's operations URL, e.g. https://my-cluster.harperdb.io:9925
|
|
12
|
-
# HARPER_CLI_REFRESH_TOKEN a long-lived refresh token; the CLI mints a short-lived operation
|
|
13
|
-
# token from it on each run, so no password is stored in CI
|
|
14
|
-
#
|
|
15
|
-
# Set both in one command — this pipes them straight from your cluster into GitHub, so the token
|
|
16
|
-
# never appears on screen or in your shell history:
|
|
17
|
-
#
|
|
18
|
-
# harper login --for-ci | gh secret set --env-file -
|
|
19
|
-
#
|
|
20
|
-
# Public repo? Drop `credential=true` from the `deploy` script — no cluster-side auth needed.
|
|
21
|
-
# See the "Deployment" section of the README for details.
|
|
22
|
-
name: Deploy to Harper Fabric
|
|
1
|
+
# Tests every pull request, and deploys to your Harper cluster when a change merges to `main`. The
|
|
2
|
+
# deploy job holds no Harper credential: its `harper` commands authenticate with GitHub's OIDC token
|
|
3
|
+
# under a trust policy on the cluster. Set that up once with
|
|
4
|
+
# `your-package-manager-run-here deploy:setup-ci` (see "Deployment" in the README).
|
|
5
|
+
name: Deploy to Harper
|
|
23
6
|
on:
|
|
24
|
-
|
|
7
|
+
pull_request:
|
|
25
8
|
push:
|
|
26
|
-
|
|
27
|
-
|
|
9
|
+
branches: [main]
|
|
10
|
+
workflow_dispatch:
|
|
28
11
|
|
|
12
|
+
permissions:
|
|
13
|
+
contents: read
|
|
14
|
+
|
|
15
|
+
# One run per branch at a time, so an older commit can't deploy after a newer one; a newer run
|
|
16
|
+
# replaces one still waiting. On a pull request, a new push cancels the run in progress.
|
|
29
17
|
concurrency:
|
|
30
|
-
group: deploy
|
|
31
|
-
cancel-in-progress:
|
|
18
|
+
group: deploy-${{ github.ref }}
|
|
19
|
+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
|
32
20
|
|
|
33
21
|
jobs:
|
|
34
|
-
|
|
22
|
+
test:
|
|
35
23
|
runs-on: ubuntu-latest
|
|
36
24
|
steps:
|
|
37
25
|
- name: Checkout code
|
|
38
|
-
uses: actions/checkout@
|
|
26
|
+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
39
27
|
with:
|
|
40
|
-
|
|
41
|
-
fetch-tags: true
|
|
28
|
+
persist-credentials: false
|
|
42
29
|
# your-package-manager-setup-step-here
|
|
43
30
|
- name: Set up Node.js
|
|
44
|
-
uses: actions/setup-node@
|
|
31
|
+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
|
45
32
|
with:
|
|
46
33
|
# your-package-manager-node-cache-here
|
|
47
34
|
node-version-file: '.nvmrc'
|
|
@@ -51,13 +38,77 @@ jobs:
|
|
|
51
38
|
run: your-package-manager-run-here test
|
|
52
39
|
- name: Run lint
|
|
53
40
|
run: your-package-manager-run-here lint
|
|
41
|
+
|
|
42
|
+
deploy:
|
|
43
|
+
needs: test
|
|
44
|
+
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
|
|
45
|
+
runs-on: ubuntu-latest
|
|
46
|
+
environment: production
|
|
47
|
+
permissions:
|
|
48
|
+
contents: read
|
|
49
|
+
id-token: write
|
|
50
|
+
env:
|
|
51
|
+
HARPER_CLI_TARGET: ${{ vars.HARPER_CLI_TARGET }}
|
|
52
|
+
steps:
|
|
53
|
+
- name: Refuse to redeploy an older commit
|
|
54
|
+
# Re-running an old run keeps its commit, which would replace a newer release.
|
|
55
|
+
if: github.run_attempt > 1
|
|
56
|
+
env:
|
|
57
|
+
GH_TOKEN: ${{ github.token }}
|
|
58
|
+
run: |
|
|
59
|
+
HEAD=$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_REF_NAME" --jq .sha)
|
|
60
|
+
[ "$HEAD" = "$GITHUB_SHA" ] || { echo "::error::$GITHUB_REF_NAME is now at $HEAD; re-running this deploy would replace it with $GITHUB_SHA"; exit 1; }
|
|
61
|
+
- name: Checkout code
|
|
62
|
+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
63
|
+
with:
|
|
64
|
+
# The deploy uploads this directory, `.git` included, so keep the job's token out of it.
|
|
65
|
+
persist-credentials: false
|
|
66
|
+
- name: Set up Node.js
|
|
67
|
+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
|
|
68
|
+
with:
|
|
69
|
+
node-version-file: '.nvmrc'
|
|
54
70
|
- name: Install Harper CLI
|
|
55
|
-
#
|
|
56
|
-
|
|
57
|
-
# deploy-by-reference lands); ^5.2.0 blocks a breaking 6.x bump.
|
|
58
|
-
run: npm install -g harper@^5.2.0
|
|
71
|
+
# 5.3 is the first CLI that authenticates with the OIDC token.
|
|
72
|
+
run: npm install --global harper@^5.3
|
|
59
73
|
- name: Deploy
|
|
60
|
-
run:
|
|
74
|
+
run: |
|
|
75
|
+
# With no target the CLI would fall back to a saved login or a local node, and succeed.
|
|
76
|
+
[ -n "$HARPER_CLI_TARGET" ] || { echo "::error::Set the HARPER_CLI_TARGET repository variable: run your-package-manager-run-here deploy:setup-ci"; exit 1; }
|
|
77
|
+
harper deploy project=your-component-name-here restart=rolling json=true > "$RUNNER_TEMP/deploy.json"
|
|
78
|
+
- name: Wait for every node to take the release
|
|
79
|
+
# The deploy returns once the node it reached has the release; the others take it in a job.
|
|
80
|
+
run: |
|
|
81
|
+
JOB_ID=$(jq -r '.restartJobId // empty' "$RUNNER_TEMP/deploy.json")
|
|
82
|
+
[ -n "$JOB_ID" ] || { echo "::error::The rolling deploy returned no restartJobId"; exit 1; }
|
|
83
|
+
LAST="could not be read"
|
|
84
|
+
for attempt in $(seq 60); do
|
|
85
|
+
sleep 10
|
|
86
|
+
harper get_job id="$JOB_ID" json=true > "$RUNNER_TEMP/job.json" || continue
|
|
87
|
+
case $(jq -r '.[0].status // "MISSING"' "$RUNNER_TEMP/job.json") in
|
|
88
|
+
COMPLETE) exit 0 ;;
|
|
89
|
+
ERROR) jq -r '.[0].message' "$RUNNER_TEMP/job.json"; exit 1 ;;
|
|
90
|
+
MISSING) LAST="was not on the node that answered; its outcome is unknown" ;;
|
|
91
|
+
*) LAST="was still running" ;;
|
|
92
|
+
esac
|
|
93
|
+
done
|
|
94
|
+
echo "::error::After 60 polls, job $JOB_ID $LAST"
|
|
95
|
+
exit 1
|
|
96
|
+
- name: Summarize
|
|
97
|
+
if: ${{ !cancelled() }}
|
|
61
98
|
env:
|
|
62
|
-
|
|
63
|
-
|
|
99
|
+
JOB_STATUS: ${{ job.status }}
|
|
100
|
+
run: |
|
|
101
|
+
[ -s "$RUNNER_TEMP/deploy.json" ] || exit 0
|
|
102
|
+
{
|
|
103
|
+
if [ "$JOB_STATUS" = success ]; then
|
|
104
|
+
echo "### Deployed your-component-name-here"
|
|
105
|
+
elif jq -e '.deployment_id' "$RUNNER_TEMP/deploy.json" > /dev/null; then
|
|
106
|
+
echo "### Deploy of your-component-name-here did not complete on every node"
|
|
107
|
+
else
|
|
108
|
+
echo "### Deploy of your-component-name-here failed"
|
|
109
|
+
fi
|
|
110
|
+
jq -r '"- Deployment: `\(.deployment_id // "unknown")`\n- Certification: `\(.certification // "not reported")`"' "$RUNNER_TEMP/deploy.json"
|
|
111
|
+
echo ""
|
|
112
|
+
echo "To go back to an earlier release, list them with \`harper list_deployments project=your-component-name-here\`,"
|
|
113
|
+
echo "then activate one with \`harper deploy project=your-component-name-here deployment_id=DEPLOYMENT_ID restart=rolling\`."
|
|
114
|
+
} >> "$GITHUB_STEP_SUMMARY"
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"test": "node --test test/*.test.ts",
|
|
14
14
|
"test:watch": "node --watch --test test/*.test.ts",
|
|
15
15
|
"build": "vite build",
|
|
16
|
-
"deploy": "harper deploy
|
|
17
|
-
"deploy:setup": "harper deploy setup=true"
|
|
16
|
+
"deploy": "harper deploy project=your-component-name-here restart=rolling",
|
|
17
|
+
"deploy:setup-ci": "harper deploy setup=true provider=github-actions project=your-component-name-here"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@harperfast/schema-codegen": "^2.0.0",
|