Skip to content

Commit

Permalink
ci: add ng-less-javascript-enabled-patch (#1739)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored Dec 25, 2023
1 parent 3e55228 commit 35acf68
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 1 deletion.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"pre-publish": "node scripts/publish/publish.js && node scripts/publish/publish-scaffold.js",
"publish:next": "bash scripts/publish/publish.sh -next",
"publish": "bash scripts/publish/publish.sh",
"sync-scaffold-version": "node scripts/publish/sync-scaffold-version.js"
"sync-scaffold-version": "node scripts/publish/sync-scaffold-version.js",
"postinstall": "ng-less-javascript-enabled-patch"
},
"dependencies": {
"@angular/animations": "^17.0.0",
Expand Down Expand Up @@ -149,6 +150,7 @@
"less-bundle-promise": "^1.0.11",
"ng-alain-sts": "^0.0.2",
"ng-alain-plugin-theme": "^16.0.0",
"ng-less-javascript-enabled-patch": "17.0.0",
"tsconfig-paths": "^4.2.0",
"@types/express": "^4.17.17",
"@types/node": "^18.18.0",
Expand Down
15 changes: 15 additions & 0 deletions schematics/ng-update/upgrade-rules/v17/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,19 @@ export class AppComponent implements OnInit {
expect(content).toContain(`private donePreloader = stepPreloader();`);
expect(content).toContain(`this.donePreloader();`);
});

it('add ng-less-javascript-enabled-patch', async () => {
const packageJsonPath = '/package.json';
tryAddFile(
tree,
packageJsonPath,
`{
"scripts": {},
"devDependencies": {}
}`
);
await runMigration();
const content = tree.readContent(packageJsonPath);
expect(content).toContain(`"ng-less-javascript-enabled-patch": "^17.0.0"`);
});
});
2 changes: 2 additions & 0 deletions schematics/ng-update/upgrade-rules/v17/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';

import { fixAngularJson } from './angularJson';
import { autoRegisterFormWidgets } from './autoRegisterFormWidgets';
import { addNljep } from './nljep';
import { updatePreloader } from './preloader';
import { removeForRoot } from './removeForRoot';
import { replaceProvideConfig } from './replaceProvideConfig';
Expand Down Expand Up @@ -34,6 +35,7 @@ export function v17Rule(): Rule {
autoRegisterFormWidgets(),
replaceProvideConfig(),
updatePreloader(),
addNljep(),
finished()
]);
};
Expand Down
21 changes: 21 additions & 0 deletions schematics/ng-update/upgrade-rules/v17/nljep.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';

import { logInfo, readPackage, writePackage } from '../../../utils';

const PACKAGE_NAME = 'ng-less-javascript-enabled-patch';
export function addNljep(): Rule {
return (tree: Tree, context: SchematicContext) => {
const json = readPackage(tree);
if (json == null) return;
if (json.devDependencies[PACKAGE_NAME]) return;

if (typeof json.scripts.postinstall !== 'string') json.scripts.postinstall = '';
if (json.scripts.postinstall.length > 0) json.scripts.postinstall += ' && ';
json.scripts.postinstall += PACKAGE_NAME;

json.devDependencies[PACKAGE_NAME] = '^17.0.0';
writePackage(tree, json);

logInfo(context, `Add [https://github.com/cipchk/${PACKAGE_NAME}] for devDependencies`);
};
}
13 changes: 13 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7245,6 +7245,7 @@ __metadata:
ng-alain-sts: "npm:^0.0.2"
ng-antd-color-picker: "npm:^1.1.0"
ng-github-button: "npm:^17.0.0"
ng-less-javascript-enabled-patch: "npm:17.0.0"
ng-packagr: "npm:^17.0.0"
ng-zorro-antd: "npm:^17.0.1"
ngx-countdown: "npm:^17.0.0"
Expand Down Expand Up @@ -12903,6 +12904,18 @@ __metadata:
languageName: node
linkType: hard

"ng-less-javascript-enabled-patch@npm:17.0.0":
version: 17.0.0
resolution: "ng-less-javascript-enabled-patch@npm:17.0.0"
peerDependencies:
"@angular-devkit/schematics": ^17.0.0
ansi-colors: ^4.0.0
bin:
ng-less-javascript-enabled-patch: index.js
checksum: 6605ee50069968499c7bfff4b3d102d2549eb9ac6d6535e084ebb2e9c6a8f978aac0148d1c06ed6ce25a2dedb213f51f48b37b0b2d78a7ed693b9fe5c3a16616
languageName: node
linkType: hard

"ng-packagr@npm:^17.0.0":
version: 17.0.0
resolution: "ng-packagr@npm:17.0.0"
Expand Down

0 comments on commit 35acf68

Please sign in to comment.