From 04c8f56dc613d1610102f9fe189963e7718499f4 Mon Sep 17 00:00:00 2001 From: cipchk Date: Tue, 2 Jul 2024 21:02:19 +0800 Subject: [PATCH 1/4] fix(cli): corrected missing setup `src/assets` of `angular.json` --- schematics/application/index.spec.ts | 4 ++++ schematics/application/index.ts | 2 ++ schematics/test.ts | 4 ++-- schematics/utils/workspace.ts | 11 +++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/schematics/application/index.spec.ts b/schematics/application/index.spec.ts index 6ab57270c..3b4c8fb01 100644 --- a/schematics/application/index.spec.ts +++ b/schematics/application/index.spec.ts @@ -23,6 +23,10 @@ describe('NgAlainSchematic: application', () => { const angualrJson = tree.readContent('angular.json'); expect(angualrJson).toContain(`fileReplacements`); }); + it('should be add src/assets', () => { + const angualrJson = tree.readContent('angular.json'); + expect(angualrJson).toContain(`"src/assets"`); + }); }); describe('#i18n', () => { diff --git a/schematics/application/index.ts b/schematics/application/index.ts index 73d556099..e3f3ebc60 100644 --- a/schematics/application/index.ts +++ b/schematics/application/index.ts @@ -27,6 +27,7 @@ import { addPackage, addSchematicCollections, addStylePreprocessorOptions, + addStyleResources, BUILD_TARGET_BUILD, BUILD_TARGET_SERVE, DEFAULT_WORKSPACE_PATH, @@ -80,6 +81,7 @@ function fixAngularJson(): Rule { if (serveTarget.options == null) serveTarget.options = {}; serveTarget.options.proxyConfig = 'proxy.conf.js'; + addStyleResources(workspace, projectName); addStylePreprocessorOptions(workspace, projectName); addSchematicCollections(workspace); addFileReplacements(workspace, projectName); diff --git a/schematics/test.ts b/schematics/test.ts index 91a5df248..17c914f51 100644 --- a/schematics/test.ts +++ b/schematics/test.ts @@ -12,8 +12,8 @@ require('source-map-support').install({ const Jasmine = require('jasmine'); const runner = new Jasmine({ projectBaseDir }); -// const files = `schematics/**/*.spec.ts`; -const files = `schematics/ng-update/upgrade-rules/V18/index.spec.ts`; +const files = `schematics/**/*.spec.ts`; +// const files = `schematics/application/index.spec.ts`; const tests = glob.sync(files).map(p => relative(projectBaseDir, p)); diff --git a/schematics/utils/workspace.ts b/schematics/utils/workspace.ts index 2540260e0..58867fad6 100644 --- a/schematics/utils/workspace.ts +++ b/schematics/utils/workspace.ts @@ -177,6 +177,17 @@ export function addStylePreprocessorOptions(workspace: WorkspaceDefinition, proj build.options.stylePreprocessorOptions['includePaths'] = includePaths; } +export function addStyleResources(workspace: WorkspaceDefinition, projectName: string): void { + const project = getProjectFromWorkspace(workspace, projectName); + if (project == null) return; + + const build = project.targets.get(BUILD_TARGET_BUILD); + if (build == null || build.options == null) return; + + if (!Array.isArray(build.options.assets)) build.options.assets = []; + (build.options.assets as string[]).push(`src/assets`); +} + export function addSchematicCollections(workspace: WorkspaceDefinition): void { const cli = workspace.extensions.cli as Record; if (cli && cli.schematicCollections) return; From e3220f0c4c95b8892a814e539f466a0fe90b73cd Mon Sep 17 00:00:00 2001 From: cipchk Date: Tue, 2 Jul 2024 21:13:11 +0800 Subject: [PATCH 2/4] release: site --- .../build-doc-site-aliyun-docker.yml | 33 +++++++++++++++++++ ...doc-site.yml => build-doc-site-docker.yml} | 4 +-- .github/workflows/deploy-site.yml | 2 +- .github/workflows/mirror-gitee.yml | 2 +- 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build-doc-site-aliyun-docker.yml rename .github/workflows/{docker-build-doc-site.yml => build-doc-site-docker.yml} (90%) diff --git a/.github/workflows/build-doc-site-aliyun-docker.yml b/.github/workflows/build-doc-site-aliyun-docker.yml new file mode 100644 index 000000000..5efc8c453 --- /dev/null +++ b/.github/workflows/build-doc-site-aliyun-docker.yml @@ -0,0 +1,33 @@ +name: build-doc-site-aliyun-docker + +# on: push +on: + push: + branches: + - master + +jobs: + website: + if: "startsWith(github.event.head_commit.message, 'release')" + runs-on: ubuntu-latest + environment: prod + steps: + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login Docker + uses: docker/login-action@v2 + with: + registry: registry.cn-hangzhou.aliyuncs.com + username: ${{ secrets.ALIYUN_USERNAME }} + password: ${{ secrets.ALIYUN_PASSWORD }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile.docs + push: true + tags: registry.cn-hangzhou.aliyuncs.com/alain/docs:latest diff --git a/.github/workflows/docker-build-doc-site.yml b/.github/workflows/build-doc-site-docker.yml similarity index 90% rename from .github/workflows/docker-build-doc-site.yml rename to .github/workflows/build-doc-site-docker.yml index 2a01ead37..ce9daab66 100644 --- a/.github/workflows/docker-build-doc-site.yml +++ b/.github/workflows/build-doc-site-docker.yml @@ -1,4 +1,4 @@ -name: docker-build-doc-site +name: build-doc-site-docker # on: push on: @@ -8,7 +8,7 @@ on: jobs: website: - if: "startsWith(github.event.commits[0].message, 'release')" + if: "startsWith(github.event.head_commit.message, 'release')" runs-on: ubuntu-latest environment: prod steps: diff --git a/.github/workflows/deploy-site.yml b/.github/workflows/deploy-site.yml index d1f69f4fd..e6c3d8ffc 100644 --- a/.github/workflows/deploy-site.yml +++ b/.github/workflows/deploy-site.yml @@ -4,7 +4,7 @@ on: push jobs: website: - if: "startsWith(github.event.commits[0].message, 'release')" + if: "startsWith(github.event.head_commit.message, 'release')" runs-on: ubuntu-latest environment: prod steps: diff --git a/.github/workflows/mirror-gitee.yml b/.github/workflows/mirror-gitee.yml index fa5c18783..231f0ee97 100644 --- a/.github/workflows/mirror-gitee.yml +++ b/.github/workflows/mirror-gitee.yml @@ -4,7 +4,7 @@ on: push jobs: to_gitee: - if: "!startsWith(github.event.commits[0].message, 'release')" + if: "!startsWith(github.event.head_commit.message, 'release')" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 663130a83c04919065fe6951f361f59ec7c4ec6e Mon Sep 17 00:00:00 2001 From: cipchk Date: Tue, 2 Jul 2024 21:22:02 +0800 Subject: [PATCH 3/4] release: try --- .github/workflows/build-doc-site-aliyun-docker.yml | 10 +++++----- .github/workflows/build-doc-site-docker.yml | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-doc-site-aliyun-docker.yml b/.github/workflows/build-doc-site-aliyun-docker.yml index 5efc8c453..a5f423d0e 100644 --- a/.github/workflows/build-doc-site-aliyun-docker.yml +++ b/.github/workflows/build-doc-site-aliyun-docker.yml @@ -1,10 +1,10 @@ name: build-doc-site-aliyun-docker -# on: push -on: - push: - branches: - - master +on: push +# on: +# push: +# branches: +# - master jobs: website: diff --git a/.github/workflows/build-doc-site-docker.yml b/.github/workflows/build-doc-site-docker.yml index ce9daab66..a53e19147 100644 --- a/.github/workflows/build-doc-site-docker.yml +++ b/.github/workflows/build-doc-site-docker.yml @@ -1,10 +1,10 @@ name: build-doc-site-docker -# on: push -on: - push: - branches: - - master +on: push +# on: +# push: +# branches: +# - master jobs: website: From 6ed4886fde1aeac7c686224297ed9e8657f1eed9 Mon Sep 17 00:00:00 2001 From: cipchk Date: Tue, 2 Jul 2024 21:25:46 +0800 Subject: [PATCH 4/4] chore: fix --- .github/workflows/build-doc-site-aliyun-docker.yml | 10 +++++----- .github/workflows/build-doc-site-docker.yml | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-doc-site-aliyun-docker.yml b/.github/workflows/build-doc-site-aliyun-docker.yml index a5f423d0e..5efc8c453 100644 --- a/.github/workflows/build-doc-site-aliyun-docker.yml +++ b/.github/workflows/build-doc-site-aliyun-docker.yml @@ -1,10 +1,10 @@ name: build-doc-site-aliyun-docker -on: push -# on: -# push: -# branches: -# - master +# on: push +on: + push: + branches: + - master jobs: website: diff --git a/.github/workflows/build-doc-site-docker.yml b/.github/workflows/build-doc-site-docker.yml index a53e19147..ce9daab66 100644 --- a/.github/workflows/build-doc-site-docker.yml +++ b/.github/workflows/build-doc-site-docker.yml @@ -1,10 +1,10 @@ name: build-doc-site-docker -on: push -# on: -# push: -# branches: -# - master +# on: push +on: + push: + branches: + - master jobs: website: