Skip to content

Commit

Permalink
feat: Add initial files for setting up the main project 🎉
Browse files Browse the repository at this point in the history
The initial project setup involves multiple files across different directories for functionality like running scripts (bin/run.js, bin/dev.js), global configurations for package manager (src/get.ts), testing configurations (test/tsconfig.json), and GitHub workflows. Changes include the addition of new files and scripts that take care of script execution, fetching package manager from configuration, and automated test configurations. A CHANGELOG.md file has also been created to keep track of project history.
  • Loading branch information
juicyjusung committed Jan 30, 2024
0 parents commit 6d656ae
Show file tree
Hide file tree
Showing 32 changed files with 9,508 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/dist
/tmp
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["oclif", "oclif-typescript", "prettier"]
}
40 changes: 40 additions & 0 deletions .github/actions/getPreReleaseTag/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: get prerelease tag
description: read package.json and return the version suffix (ex 'beta' if x.y.z-beta.0)

outputs:
tag:
value: ${{ steps.tag.outputs.match }}
description: version suffix (ex 'beta' if x.y.z-beta.0 ), if exists in package.json
version:
value: ${{ steps.packageVersion.outputs.prop }}
description: version from pjson

runs:
using: composites
steps:
- uses: notiz-dev/github-action-json-property@7a701887f4b568b23eb7b78bb0fc49aaeb1b68d3
id: packageVersion
with:
path: "package.json"
prop_path: "version"

- run: echo "found version ${{ steps.packageVersion.outputs.prop }}"
shell: bash

- uses: booxmedialtd/ws-action-parse-semver@7784200024d6b3fc01253e617ec0168daf603de3
id: versionSuffix
with:
input_string: ${{ steps.packageVersion.outputs.prop }}

- run: echo "found prerelease ${{ steps.versionSuffix.outputs.prerelease }}"
shell: bash

- uses: actions-ecosystem/action-regex-match@d50fd2e7a37d0e617aea3d7ada663bd56862b9cc
id: tag
with:
text: ${{ steps.versionSuffix.outputs.prerelease }}
# at this point, we have just the prerelease section, but it includes the final .0 or whatever
regex: '.*(?=\.\d+)'

- run: echo "found tag ${{ steps.tag.outputs.match }}"
shell: bash
11 changes: 11 additions & 0 deletions .github/actions/gitConfig/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: gitConfig
description: "Sets git username/email and push behavior"
runs:
using: composite
steps:
- run: git config --global push.default current
shell: bash
- run: git config --global user.email [email protected]
shell: bash
- run: git config --global user.name juicyjusung-bot
shell: bash
43 changes: 43 additions & 0 deletions .github/actions/versionInfo/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: version-info
description: gets information about a npm tag or version

inputs:
version:
required: true
description: an npm version number (like 7.180.8) or an npm tag like latest/latest-rc
npmPackage:
required: false
default: sfdx-cli
description: full npm package name, including namespace if one exists

outputs:
version:
value: ${{ steps.getNumericalVersion.outputs.version }}
description: guaranteed to be an npm number, even if a tag was passed in
url:
value: https://developer.salesforce.com/media/salesforce-cli/${{ steps.getCli.outputs.cli }}/versions/${{ steps.getNumericalVersion.outputs.version }}/${{ steps.getSha.outputs.sha }}/${{ steps.getCli.outputs.cli }}-v${{ steps.getNumericalVersion.outputs.version }}-${{ steps.getSha.outputs.sha }}-linux-x64.tar.xz
description: url where the xz tarball for this version can be downloaded
sha:
description: short sha for the matching version
value: ${{ steps.getSha.outputs.sha }}

runs:
using: composite
steps:
- id: getSha
shell: bash
run: echo "sha=$(npm view ${{ inputs.npmPackage }}@${{ inputs.version }} --json | jq -r '.gitHead[0:7]')" >> "$GITHUB_OUTPUT"

- id: getNumericalVersion
shell: bash
run: echo "version=$(npm view ${{ inputs.npmPackage }}@${{ inputs.version }} --json | jq -r '.version')" >> "$GITHUB_OUTPUT"

- id: getCli
shell: bash
run: echo "cli=$(npm view ${{ inputs.npmPackage }}@${{ inputs.version }} --json | jq -r '.oclif.bin')" >> "$GITHUB_OUTPUT"

- run: echo "regex found version ${{ steps.getNumericalVersion.outputs.version }} with sha ${{ steps.getSha.outputs.sha }} for cli ${{ steps.getCli.outputs.cli }}"
shell: bash

- run: echo "xz url is https://developer.salesforce.com/media/salesforce-cli/${{ steps.getCli.outputs.cli }}/versions/${{ steps.getNumericalVersion.outputs.version }}/${{ steps.getSha.outputs.sha }}/${{ steps.getCli.outputs.cli }}-v${{ steps.getNumericalVersion.outputs.version }}-${{ steps.getSha.outputs.sha }}-linux-x64.tar.xz"
shell: bash
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 2
updates:
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'weekly'
day: 'saturday'
versioning-strategy: 'increase'
labels:
- 'dependencies'
open-pull-requests-limit: 5
pull-request-branch-name:
separator: '-'
commit-message:
# cause a release for non-dev-deps
prefix: fix(deps)
# no release for dev-deps
prefix-development: chore(dev-deps)
ignore:
- dependency-name: '@salesforce/dev-scripts'
- dependency-name: '*'
update-types: ['version-update:semver-major']
10 changes: 10 additions & 0 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: automerge
on:
workflow_dispatch:
schedule:
- cron: '17 2,5,8,11 * * *'

jobs:
automerge:
uses: oclif/github-workflows/.github/workflows/automerge.yml@main
secrets: inherit
43 changes: 43 additions & 0 deletions .github/workflows/failureNotifications.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: failureNotifications

on:
workflow_run:
workflows:
- version, tag and github release
- publish
types:
- completed

jobs:
failure-notify:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- name: Announce Failure
id: slack
uses: slackapi/[email protected]
env:
# for non-CLI-team-owned plugins, you can send this anywhere you like
SLACK_WEBHOOK_URL: ${{ secrets.CLI_ALERTS_SLACK_WEBHOOK }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
with:
payload: |
{
"text": "${{ github.event.workflow_run.name }} failed: ${{ github.event.workflow_run.repository.name }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":bh-alert: ${{ github.event.workflow_run.name }} failed: ${{ github.event.workflow_run.repository.name }} :bh-alert:"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Repo: ${{ github.event.workflow_run.repository.html_url }}\nWorkflow name: `${{ github.event.workflow_run.name }}`\nJob url: ${{ github.event.workflow_run.html_url }}"
}
}
]
}
36 changes: 36 additions & 0 deletions .github/workflows/manualRelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: manual release

on:
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
- name: Conventional Changelog Action
id: changelog
uses: TriPSs/conventional-changelog-action@d360fad3a42feca6462f72c97c165d60a02d4bf2
# overriding some of the basic behaviors to just get the changelog
with:
git-user-name: svc-cli-bot
git-user-email: [email protected]
github-token: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
output-file: false
# always do the release, even if there are no semantic commits
skip-on-empty: false
tag-prefix: ''
- uses: notiz-dev/github-action-json-property@7a701887f4b568b23eb7b78bb0fc49aaeb1b68d3
id: packageVersion
with:
path: 'package.json'
prop_path: 'version'
- name: Create Github Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.SVC_CLI_BOT_GITHUB_TOKEN }}
with:
tag_name: ${{ steps.packageVersion.outputs.prop }}
release_name: ${{ steps.packageVersion.outputs.prop }}
23 changes: 23 additions & 0 deletions .github/workflows/notify-slack-on-pr-open.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Pull Request Slack Notification

on:
pull_request:
types: [opened, reopened]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Notify Slack on PR open
env:
WEBHOOK_URL : ${{ secrets.CLI_TEAM_SLACK_WEBHOOK_URL }}
PULL_REQUEST_AUTHOR_ICON_URL : ${{ github.event.pull_request.user.avatar_url }}
PULL_REQUEST_AUTHOR_NAME : ${{ github.event.pull_request.user.login }}
PULL_REQUEST_AUTHOR_PROFILE_URL: ${{ github.event.pull_request.user.html_url }}
PULL_REQUEST_BASE_BRANCH_NAME : ${{ github.event.pull_request.base.ref }}
PULL_REQUEST_COMPARE_BRANCH_NAME : ${{ github.event.pull_request.head.ref }}
PULL_REQUEST_NUMBER : ${{ github.event.pull_request.number }}
PULL_REQUEST_REPO: ${{ github.event.pull_request.head.repo.name }}
PULL_REQUEST_TITLE : ${{ github.event.pull_request.title }}
PULL_REQUEST_URL : ${{ github.event.pull_request.html_url }}
uses: salesforcecli/github-workflows/.github/actions/prNotification@main
46 changes: 46 additions & 0 deletions .github/workflows/onPushToMain.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# test
name: version, tag and github release

on:
push:
branches: [main]
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/getPreReleaseTag
id: distTag
if: inputs.prerelease

- name: prerelease package.json validation
if: inputs.prerelease && !steps.distTag.outputs.tag
uses: actions/github-script@v3
with:
script: |
core.setFailed('Prerelease requires a dist tag name in your package.json like beta in 1.1.1-beta.0')
- name: Conventional Changelog Action
id: changelog
uses: TriPSs/conventional-changelog-action@9962c3267b32873dbc552a38a8397194361e1101
with:
git-user-name: juicyjusung-bot
git-user-email: [email protected]
github-token: ${{ secrets.GITHUB_TOKEN }}
tag-prefix: ""
# Setting 'release-count' to 0 will keep ALL releases in the change log (no pruning)
release-count: "0"
pre-release: ${{ inputs.prerelease }}
pre-release-identifier: ${{ steps.distTag.outputs.tag }}
# ternary-ish: https://github.com/actions/runner/issues/409#issuecomment-752775072
output-file: ${{ inputs.prerelease && 'false' || 'CHANGELOG.md' }} # If prerelease, do not write the changelog file
- name: Create Github Release
uses: actions/create-release@v1
if: ${{ steps.changelog.outputs.skipped == 'false' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.changelog.outputs.tag }}
release_name: ${{ steps.changelog.outputs.tag }}
body: ${{ steps.changelog.outputs.clean_changelog }}
prerelease: ${{ inputs.prerelease }}
19 changes: 19 additions & 0 deletions .github/workflows/onRelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: publish

on:
release:
types: [released]
# support manual release in case something goes wrong and needs to be repeated or tested
workflow_dispatch:
inputs:
tag:
description: tag that needs to publish
type: string
required: true
jobs:
npm:
uses: oclif/github-workflows/.github/workflows/npmPublish.yml@main
with:
tag: latest
githubTag: ${{ github.event.release.tag_name || inputs.tag }}
secrets: inherit
9 changes: 9 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: tests
on:
push:
branches-ignore: [main]
workflow_dispatch:

jobs:
unit-tests:
uses: oclif/github-workflows/.github/workflows/unitTest.yml@main
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
**/.DS_Store
*-debug.log
*-error.log
/.idea
/.nyc_output
/dist
/lib
/package-lock.json
/tmp
node_modules
oclif.lock
oclif.manifest.json
15 changes: 15 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"require": [
"ts-node/register"
],
"watch-extensions": [
"ts"
],
"recursive": true,
"reporter": "spec",
"timeout": 60000,
"node-option": [
"loader=ts-node/esm",
"experimental-specifier-resolution=node"
]
}
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"@oclif/prettier-config"
Loading

0 comments on commit 6d656ae

Please sign in to comment.