mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
feat: Make pushing linkables happen automatically when using re-usable build script
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
parent
355ff3296a
commit
7e66181be5
@ -36,7 +36,8 @@
|
|||||||
"tailwindcss": "^3.3.2",
|
"tailwindcss": "^3.3.2",
|
||||||
"ts-loader": "^9.4.1",
|
"ts-loader": "^9.4.1",
|
||||||
"webpack": "^5.81.0",
|
"webpack": "^5.81.0",
|
||||||
"webpack-cli": "^4.10.0"
|
"webpack-cli": "^4.10.0",
|
||||||
|
"@ogre-tools/linkable": "^15.8.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@ogre-tools/fp": "^15.8.0",
|
"@ogre-tools/fp": "^15.8.0",
|
||||||
|
|||||||
@ -47,6 +47,27 @@ describe("do-webpack-build", () => {
|
|||||||
expect(logSuccessMock).toHaveBeenCalledWith("some-stdout");
|
expect(logSuccessMock).toHaveBeenCalledWith("some-stdout");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("makes the built package available for local packages in development that link to it", () => {
|
||||||
|
expect(execMock).toHaveBeenCalledWith("linkable-push");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not finish script yet", async () => {
|
||||||
|
const promiseStatus = await getPromiseStatus(actualPromise);
|
||||||
|
|
||||||
|
expect(promiseStatus.fulfilled).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("when linking resolves with stdout", () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
logSuccessMock.mockClear();
|
||||||
|
|
||||||
|
await execMock.resolve({ stdout: "some-other-stdout", stderr: "" });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("logs the stdout", () => {
|
||||||
|
expect(logSuccessMock).toHaveBeenCalledWith("some-other-stdout");
|
||||||
|
});
|
||||||
|
|
||||||
it("script finishes", async () => {
|
it("script finishes", async () => {
|
||||||
const promiseStatus = await getPromiseStatus(actualPromise);
|
const promiseStatus = await getPromiseStatus(actualPromise);
|
||||||
|
|
||||||
@ -54,6 +75,43 @@ describe("do-webpack-build", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("when linking resolves with stderr", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
logSuccessMock.mockClear();
|
||||||
|
|
||||||
|
execMock.resolve({ stdout: "", stderr: "some-other-stderr" });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not log success", () => {
|
||||||
|
actualPromise.catch(() => {});
|
||||||
|
|
||||||
|
expect(logSuccessMock).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("throws", () => {
|
||||||
|
return expect(actualPromise).rejects.toThrow("some-other-stderr");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("when linking rejects", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
logSuccessMock.mockClear();
|
||||||
|
|
||||||
|
execMock.reject(new Error("some-other-error"));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not log success", () => {
|
||||||
|
actualPromise.catch(() => {});
|
||||||
|
|
||||||
|
expect(logSuccessMock).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("throws", () => {
|
||||||
|
return expect(actualPromise).rejects.toThrow("some-other-error");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("when webpack resolves with stderr", () => {
|
describe("when webpack resolves with stderr", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
execMock.resolve({ stdout: "", stderr: "some-stderr" });
|
execMock.resolve({ stdout: "", stderr: "some-stderr" });
|
||||||
|
|||||||
@ -11,8 +11,8 @@ export const doWebpackBuildInjectable = getInjectable({
|
|||||||
const exec = di.inject(execInjectable);
|
const exec = di.inject(execInjectable);
|
||||||
const logSuccess = di.inject(logSuccessInjectable);
|
const logSuccess = di.inject(logSuccessInjectable);
|
||||||
|
|
||||||
return async () => {
|
const execWithResultHandling = async (command: string) => {
|
||||||
const { stdout, stderr } = await exec("webpack");
|
const { stdout, stderr } = await exec(command);
|
||||||
|
|
||||||
if (stderr) {
|
if (stderr) {
|
||||||
throw new Error(stderr);
|
throw new Error(stderr);
|
||||||
@ -20,5 +20,11 @@ export const doWebpackBuildInjectable = getInjectable({
|
|||||||
|
|
||||||
logSuccess(stdout);
|
logSuccess(stdout);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return async () => {
|
||||||
|
await execWithResultHandling("webpack");
|
||||||
|
|
||||||
|
await execWithResultHandling("linkable-push");
|
||||||
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user