Skip to content

Commit

Permalink
Migration
Browse files Browse the repository at this point in the history
  • Loading branch information
BSekula committed May 22, 2024
1 parent 00e8955 commit 8c0ceec
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 26 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/release-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,18 @@ jobs:
with:
dry-run-flag: ${{ inputs.dry-run-flag }}
- uses: ./.github/actions/download-node-modules-and-artifacts
- name: build libraries
- name: Set libraries versions
run: |
set -u;
./scripts/update-version.sh -gnu || exit 1;
- name: Set migrations
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const setMigrations = require('./scripts/github/release/set-migrations.js');
setMigrations();
- name: Build libraries
run: |
npx nx affected:build $NX_CALCULATION_FLAGS --prod --exclude="demoshell" --skip-nx-cache
npx nx affected $NX_CALCULATION_FLAGS --target=pretheme
npx nx affected $NX_CALCULATION_FLAGS --target=build-schematics
Expand Down
22 changes: 9 additions & 13 deletions lib/core/migrations/move-out-alfresco-api/move-out-alfresco-api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,22 +24,18 @@ import { Project } from 'ts-morph';
* @param path string
* @param callback function
*/
function visitAllFiles(
tree: Tree,
path: string,
callback: (filePath: string, hostTree: Tree, project: Project) => void
) {
function visitAllFiles(tree: Tree, path: string, callback: (filePath: string, hostTree: Tree, project: Project) => void) {
const project = new Project();

tree.children(path).forEach((fileName) => {
const filePath = `${path}/${fileName}`;
if (!tree.isFile(filePath)) {
visitAllFiles(tree, filePath, callback);
} else {
callback(filePath, tree, project);
}
const filePath = `${path}/${fileName}`;
if (!tree.isFile(filePath)) {
visitAllFiles(tree, filePath, callback);
} else {
callback(filePath, tree, project);
}
});
}
}

/**
* Moving out alfresco-api from adf core
Expand Down
5 changes: 5 additions & 0 deletions lib/core/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
"input": "./src/lib/app-config",
"output": "/"
},
{
"glob": "nx-migrations.json",
"input": "./",
"output": "/"
},
{
"glob": "**/*.scss",
"input": "./src/lib",
Expand Down
File renamed without changes.
5 changes: 4 additions & 1 deletion lib/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
],
"license": "Apache-2.0",
"ng-update": {
"migrations": "./migrations.json"
"migrations": "./schematics/migrations/collection.json"
},
"nx-migrations": {
"migrations": "./nx-migrations.json"
}
}
10 changes: 0 additions & 10 deletions lib/core/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@
]
}
},
"build-nx-migrations": {
"executor": "nx:run-commands",
"options": {
"commands": [
{
"command": "npx tsc -p lib/core/tsconfig.nx.migrations.json && cp lib/core/migrations.json dist/libs/core/migrations.json"
}
]
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
Expand Down
2 changes: 1 addition & 1 deletion lib/core/schematics/migrations/collection.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "../../../node_modules/@angular-devkit/schematics/collection-schema.json",
"schematics": {
"update-alfresco-api-imports": {
"move-out-alfresco-api": {
"description": "Update alfresco-api imports",
"version": "7.0.0",
"factory": "./7_0_0/index#updateAlfrescoApiImports"
Expand Down
35 changes: 35 additions & 0 deletions scripts/github/release/set-migrations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const fs = require('fs');
// const semver = require('semver');

module.exports = async () => {
const corePackagePath = 'lib/core/package.json';
const coreSchematicsPath = 'lib/core/schematics/migrations/collection.json';
const coreNxMigrationPath = 'lib/core/nx-migrations.json';

const rawCorePackage = fs.readFileSync(corePackagePath, 'utf8');
const corePackage = JSON.parse(rawCorePackage);

const rawCoreSchematics = fs.readFileSync(coreSchematicsPath, 'utf8');
const coreSchematics = JSON.parse(rawCoreSchematics);

const rawCoreNxMigration = fs.readFileSync(coreNxMigrationPath, 'utf8');
const coreNxMigration = JSON.parse(rawCoreNxMigration);

const coreVersion = corePackage.version;
console.log({ coreVersion }, { coreNxMigration }, { coreSchematics });

const coreMigrations = [
{
name: 'move-out-alfresco-api',
version: '<=7.0.0'
}
];

coreMigrations.forEach((migration) => {
coreNxMigration['generators'][migration.name]?.['version'] === coreVersion;
coreSchematics['schematics'][migration.name]?.['version'] === coreVersion;
});

fs.writeFileSync(coreNxMigrationPath, JSON.stringify(coreNxMigration));
fs.writeFileSync(coreSchematicsPath, JSON.stringify(coreSchematics));
};

0 comments on commit 8c0ceec

Please sign in to comment.