Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@types/jest": "^26.0.14",
"antd": "4.12.2",
"css-loader": "^5.1.3",
"execa": "^5.1.1",
"file-loader": "^6.2.0",
"fs-extra": "^9.0.0",
"react": "^17.0.0",
Expand Down
1,060 changes: 1,060 additions & 0 deletions src/__test_resources__/aui4_ui_folder.json

Large diffs are not rendered by default.

1,695 changes: 1,695 additions & 0 deletions src/__test_resources__/servers.json

Large diffs are not rendered by default.

1,952 changes: 1,952 additions & 0 deletions src/cli/__snapshots__/cli.test.ts.snap

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/cli/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ yargs
const servers = await fs.readJSON(serversPath);
const migratedUIFolder = migrateUIFolder(legacyUIFolder, servers);
await fs.writeJSON(outputPath, migratedUIFolder, { spaces: 2 });
// FIXME Rely on yargs instead of having to call process.exit manually.
// See https://support.activeviam.com/jira/browse/UI-7198
process.exit(0);
}
)
.demandCommand(1)
Expand Down
38 changes: 38 additions & 0 deletions src/cli/cli.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import execa from "execa";
import fs from "fs-extra";
import path from "path";
import pkgDir from "pkg-dir";
import os from "os";

const binPath = path.join(pkgDir.sync()!, "bin");

// Make sure to rebuild the package before running the test.
describe("Migration CLI", () => {
it("creates a json file corresponding to the input AUI4 content migrated to AUI5", async () => {
const pathToTmpDirectory = await fs.mkdtemp(`${os.tmpdir()}${path.sep}`);
const outputFileName = "aui5_ui_folder.json";
const pathToTmpOutput = path.join(pathToTmpDirectory, outputFileName);

try {
// Migrate through the CLI.
await execa("node", [
binPath,
"-i",
path.join(__dirname, "..", "__test_resources__", "aui4_ui_folder.json"),
"-s",
path.join(__dirname, "..", "__test_resources__", "servers.json"),
"-o",
pathToTmpOutput,
]);

const outputFiles = await fs.readdir(pathToTmpDirectory);
expect(outputFiles.length).toBe(1);
expect(outputFiles[0]).toBe(outputFileName);

const migratedContent = await fs.readJson(pathToTmpOutput);
expect(migratedContent).toMatchSnapshot();
} finally {
await fs.rm(pathToTmpDirectory, { force: true, recursive: true });
}
});
});
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6858,7 +6858,7 @@ exec-sh@^0.3.2:
resolved "https://registry.yarnpkg.com/exec-sh/-/exec-sh-0.3.6.tgz#ff264f9e325519a60cb5e273692943483cca63bc"
integrity sha512-nQn+hI3yp+oD0huYhKwvYI32+JFeq+XkNcD1GAo3Y/MjxsfVGmrrzrnzjWiNY6f+pUCP440fThsFh5gZrRAU/w==

[email protected], execa@^5.0.0:
[email protected], execa@^5.0.0, execa@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd"
integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==
Expand Down