Skip to content

Commit

Permalink
fix(cli): corrected missing setup src/assets of angular.json (#1809)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored Jul 2, 2024
1 parent 0c97e89 commit 18166bc
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 6 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/build-doc-site-aliyun-docker.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: docker-build-doc-site
name: build-doc-site-docker

# on: push
on:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mirror-gitee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions schematics/application/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 2 additions & 0 deletions schematics/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
addPackage,
addSchematicCollections,
addStylePreprocessorOptions,
addStyleResources,
BUILD_TARGET_BUILD,
BUILD_TARGET_SERVE,
DEFAULT_WORKSPACE_PATH,
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions schematics/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
11 changes: 11 additions & 0 deletions schematics/utils/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown>;
if (cli && cli.schematicCollections) return;
Expand Down

0 comments on commit 18166bc

Please sign in to comment.