Skip to content

Commit 3e36e05

Browse files
committed
chore: move the libraries code into a new repo
1 parent 7d61223 commit 3e36e05

File tree

134 files changed

+20590
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+20590
-1
lines changed

.eslintignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
**/node_modules
3+
dist
4+
**/src/models.ts
5+
**/*.stories.tsx
6+
coverage
7+
generated-prisma-client
8+
**/amplication_modules

.eslintrc.json

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"root": true,
3+
"plugins": ["perfectionist", "@nx"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx"],
7+
"extends": ["plugin:@nx/typescript"],
8+
"rules": {
9+
"no-prototype-builtins": "off",
10+
"no-restricted-imports": [
11+
"error",
12+
{
13+
"patterns": [
14+
{
15+
"group": ["@amplication/*/src/*"],
16+
"message": "usage of from inners of methods modules not allowed."
17+
}
18+
]
19+
}
20+
]
21+
}
22+
},
23+
{
24+
"files": ["*.js", "*.jsx"],
25+
"extends": ["plugin:@nx/javascript"],
26+
"rules": {}
27+
},
28+
{
29+
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
30+
"env": {
31+
"jest": true
32+
},
33+
"rules": {}
34+
},
35+
{
36+
"files": ["*.json"],
37+
"parser": "jsonc-eslint-parser",
38+
"rules": {
39+
"@nx/dependency-checks": "error"
40+
}
41+
}
42+
]
43+
}

.github/ISSUE_TEMPLATE/config.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: No issues undertaking
4+
url: https://github.com/amplication/amplication/issues/new/choose
5+
about: We are not tracking issues in this repo. To report an issue related to this repo, please open the issue on our main repo amplication/amplication

.github/PULL_REQUEST_TEMPLATE.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Fixes: amplication/amplication#[issue-number]
2+
3+
## PR Details
4+
5+
<!-- Explain the details for making this change. What existing problem does the pull request solve? -->
6+
7+
## PR Checklist
8+
9+
- [ ] Tests for the changes have been added
10+
- [ ] `npm test` doesn't throw any error
11+
12+
IMPORTANT: Please review the [CONTRIBUTING.md](https://github.com/amplication/amplication/blob/master/CODE_OF_CONDUCT.md) file for detailed contributing guidelines.

.github/dependabot.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "npm"
4+
directory: "/"
5+
target-branch: "next"
6+
schedule:
7+
interval: "weekly"
8+
ignore:
9+
- dependency-name: "@nx/**" # we need to use nx migrate instead
10+
- dependency-name: "react**"
11+
open-pull-requests-limit: 3
12+
- package-ecosystem: "npm"
13+
directory: "/packages/data-service-generator/src/"
14+
target-branch: "next"
15+
schedule:
16+
interval: "weekly"
17+
open-pull-requests-limit: 5
18+
19+
- package-ecosystem: "docker"
20+
directory: "/"
21+
target-branch: "next"
22+
schedule:
23+
interval: "daily"
24+
ignore:
25+
- dependency-name: "*"
26+
update-types:
27+
["version-update:semver-major", "version-update:semver-minor"]

.github/workflows/README.md

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# GitHub Actions
2+
3+
## Continuous Integration
4+
5+
The `continuous integration` workflow is responsible for linting, testing, building and evaluating projects that are affected by a change, and in some cases deploying them to an environment.
6+
7+
It is triggered in the following way:
8+
9+
1. on push to `main` and `next` (no need to keep a pull request `next->main` open).
10+
2. on commits on a branch with an open PR.
11+
3. manually (it supports Nx all, to force ci steps for all projects, and Nx skip cache options).
12+
13+
### Release
14+
15+
On a successfully completed `continuous integration` step for `main` and `next` branches the `release` step will ship the built affected application to the environments, leveraging `release.template.yml`.
16+
17+
The `release.template.yml` is in charge of building and pushing new docker images and deploying in the new clusters by leveraging the new `deployment.template.yml` and it is executed only on a successfully completed `continuous integration` step for `main` and `next` branches.
18+
19+
> In order to package a project as a container, the project needs to have `package:container` nx target defined in its `project.json`
20+
21+
> In order to package a project as a static website and push to s3, the project needs to have `deploy:static` nx target defined in its `project.json`
22+
23+
> In order to deploy a project as a container, the project needs to have `deploy:container` nx target defined in its `project.json`
24+
25+
Example
26+
```json
27+
{
28+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
29+
// ...
30+
"targets": {
31+
// ...
32+
"package:container": {
33+
"executor": "@nx-tools/nx-package:container",
34+
"options": {
35+
"push": false,
36+
"tags": ["amplication/git-pull-service"]
37+
}
38+
},
39+
"deploy:container": { "executor": "nx:run-commands" }
40+
// ...
41+
}
42+
```
43+
44+
> ⚠️ Pull requests containing changes to any workflow template needs to target `main` to become effective since the any workflow using of these template will reference the latest `main` version of them
45+
46+
## Development
47+
48+
To be able to locally develop a workflow the following tools are required: [docker](https://docs.docker.com/get-docker/) and [act](https://github.com/nektos/act#installation). In our setup we use templates workflows in combination with the `workflow_call` option, this is however not supported by `act` at the moment of writing.
49+
50+
### Example commands
51+
52+
```
53+
# Command structure:
54+
act [<event>] [options]
55+
56+
# List all actions for all events:
57+
act -l
58+
59+
# Run the default (`push`) event:
60+
act
61+
62+
# Run a specific event:
63+
act pull_request
64+
65+
# Run a specific job:
66+
act -j test
67+
68+
# Run a job in a specific workflow (useful if you have duplicate job names)
69+
act -j lint -W .github/workflows/checks.yml
70+
```

.github/workflows/ci.yml

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Continuous Integration
2+
concurrency: ${{ github.ref }}
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
nx-base:
8+
type: string
9+
description: Commit SHA, branch or tag name used by Nx in the affected jobs.
10+
required: true
11+
default: next
12+
nx-skip-cache:
13+
type: boolean
14+
description: Rerun the tasks even when the results are available in the cache.
15+
default: false
16+
nx-force-all:
17+
type: boolean
18+
description: Forces Nx to consider all projects (apps and libs) as affected.
19+
default: false
20+
pull_request:
21+
types: [opened, reopened, synchronize]
22+
push:
23+
branches:
24+
- main
25+
- next
26+
27+
env:
28+
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
29+
NX_BRANCH: ${{ github.head_ref || github.ref_name }}
30+
NX_FORCE_ALL: ${{ fromJSON('["", "--all"]')[ inputs.nx-force-all ] }} # This relies on type coercion, an implicit cast from boolean true to 1 or false to 0, which is then used as array index.
31+
NX_AFFECTED_OR_ALL: ${{ fromJSON('["affected", "run-many --all"]')[ inputs.nx-force-all ] }}
32+
NX_SKIP_NX_CACHE: ${{ inputs.nx-skip-cache || false }}
33+
BASE: ${{ github.base_ref || inputs.nx-base || github.event.repository.default_branch }}
34+
35+
jobs:
36+
ci:
37+
name: Continuous Integration
38+
if: github.event_name == 'push' || ( github.event_name == 'pull_request' && github.head_ref != 'next' ) || github.event_name == 'workflow_dispatch'
39+
runs-on: ubuntu-20.04
40+
steps:
41+
- uses: actions/checkout@v4
42+
with:
43+
fetch-depth: 0
44+
45+
- uses: nrwl/nx-set-shas@v4
46+
with:
47+
main-branch-name: ${{ env.BASE }}
48+
49+
- uses: actions/setup-node@v4
50+
with:
51+
node-version-file: "package.json"
52+
cache: "npm"
53+
cache-dependency-path: "**/package-lock.json"
54+
55+
- name: Cache global node modules
56+
id: cache-node-modules
57+
uses: actions/cache@v4
58+
env:
59+
cache-name: cache-node-modules
60+
with:
61+
path: node_modules
62+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
63+
64+
- name: Install Dependencies
65+
if: ${{ steps.cache-node-modules.outputs.cache-hit != 'true' }}
66+
run: npm ci
67+
68+
- name: Nx Format Check
69+
run: npx nx format:check $NX_FORCE_ALL
70+
71+
- name: Lint
72+
run: npx nx $NX_AFFECTED_OR_ALL --target=lint --parallel=3
73+
74+
- name: Build
75+
run: |
76+
npx nx $NX_AFFECTED_OR_ALL --target=build --parallel=3
77+
npx nx $NX_AFFECTED_OR_ALL --target=postbuild --parallel=3
78+
79+
- name: Get number of CPU cores
80+
uses: SimenB/github-actions-cpu-cores@v2
81+
id: cpu-cores
82+
83+
- name: Test
84+
env:
85+
NODE_OPTIONS: "--max_old_space_size=4096"
86+
run: npx nx $NX_AFFECTED_OR_ALL --target=test --coverage --maxWorkers=${{ steps.cpu-cores.outputs.count }}
87+
88+
nx:
89+
name: Nx
90+
needs: ci
91+
if: ${{ github.ref_name == github.event.repository.default_branch || github.ref_name == 'next' }}
92+
uses: ./.github/workflows/nx.template.yml
93+
with:
94+
nx-head: ${{ github.head_ref && format('refs/pull/{0}/merge', github.event.number) || github.ref_name }}
95+
nx-base: ${{ github.base_ref || inputs.nx-base || github.event.repository.default_branch }}
96+
nx-skip-cache: ${{ inputs.nx-skip-cache || false }} # This relies on type coercion, an implicit cast from boolean true to 1 or false to 0, which is then used as array index.
97+
nx-force-all: ${{ inputs.nx-force-all || false }}
98+
99+
release:
100+
name: Release
101+
needs: nx
102+
uses: amplication/amplication/.github/workflows/release.template.yml@master
103+
if: ${{ github.ref_name == github.event.repository.default_branch }}
104+
with:
105+
default-branch: ${{ github.event.repository.default_branch }}
106+
branch: ${{ github.ref_name }}
107+
enable-custom-tags: true
108+
affected-apps: ${{ needs.nx.outputs.affected-apps }}
109+
affected-lib: ${{ needs.nx.outputs.affected-lib }}
110+
affected-package-container: ${{ needs.nx.outputs.affected-package-container }}
111+
affected-deploy-static: ${{ needs.nx.outputs.affected-deploy-static }}
112+
affected-deploy-container: ${{ needs.nx.outputs.affected-deploy-container }}
113+
secrets:
114+
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
115+
ECR_AWS_ACCESS_KEY_ID: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }}
116+
ECR_AWS_SECRET_ACCESS_KEY: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }}
117+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
118+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

.github/workflows/docs-send-pr.yml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build-and-deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: "20.12.2"
19+
cache: "npm"
20+
21+
- name: Install dependencies
22+
run: npm ci
23+
24+
- name: Generate documentation
25+
run: npm run docs
26+
27+
- name: Setup Git
28+
run: |
29+
git config --global user.name "GitHub Actions Bot"
30+
git config --global user.email "[email protected]"
31+
32+
- name: Create temporary repository with documentation
33+
run: |
34+
# Create a new temporary repository
35+
mkdir -p temp-repo/docs
36+
cd temp-repo
37+
git init
38+
39+
# Copy documentation
40+
cp -r ../docs/* docs/
41+
touch docs/.nojekyll
42+
43+
# Commit changes
44+
git add .
45+
git commit -m "docs: update documentation"
46+
47+
# Push to GitHub (this creates a fork automatically)
48+
# Using GITHUB_TOKEN for this push to your own repository
49+
git remote add origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository_owner }}/ast-types-docs-temp.git
50+
git branch -M main
51+
git push -f origin main
52+
53+
- name: Create Pull Request to target repository
54+
uses: actions/github-script@v6
55+
with:
56+
github-token: ${{ secrets.EXTERNAL_REPO_TOKEN }}
57+
script: |
58+
const owner = 'amplication';
59+
const repo = 'ast-types';
60+
61+
try {
62+
const response = await github.rest.pulls.create({
63+
owner,
64+
repo,
65+
title: 'Update documentation',
66+
body: 'This PR updates the documentation based on the latest changes in the main repository.\n\nAutomated PR created by GitHub Actions.',
67+
head: `${{ github.repository_owner }}:main`,
68+
base: 'main'
69+
});
70+
71+
console.log(`Pull request created: ${response.data.html_url}`);
72+
} catch (error) {
73+
console.error('Error creating pull request:', error);
74+
75+
// If PR already exists, we'll just log and continue
76+
if (error.message.includes('A pull request already exists')) {
77+
console.log('A pull request already exists for this branch.');
78+
} else {
79+
throw error;
80+
}
81+
}

0 commit comments

Comments
 (0)