Skip to content

Commit 1008a1e

Browse files
authored
fix(packages): disable non-functional registry login attempt on upgrade (#1528)
1 parent f8e4b59 commit 1008a1e

File tree

3 files changed

+76
-61
lines changed

3 files changed

+76
-61
lines changed

packages/core/packages/PackageManager.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import { App, ProjectConfig, Util } from "../util";
66

77
import componentsConfig = require("./components");
88

9+
/** @internal */
10+
export const REGISTRY_ATTEMPT_LOGIN = false;
11+
912
export class PackageManager {
1013
private static ossPackage: string = "ignite-ui";
1114
private static fullPackage: string = "@infragistics/ignite-ui-full";
@@ -45,6 +48,10 @@ export class PackageManager {
4548
const version = ossVersion ? `@"${ossVersion}"` : "";
4649
const errorMsg = "Something went wrong, " +
4750
"please follow the steps in this guide: https://www.igniteui.com/help/using-ignite-ui-npm-packages";
51+
Util.log(
52+
"The project you've created requires the full version of Ignite UI from Infragistics private feed.",
53+
"gray"
54+
);
4855
// fallback to @latest, in case when igniteui-full does not have a matching version to ossVersion
4956
// ex: "ignite-ui": "^21.1.13" BUT --> ignite-ui-full": "^21.1.11" (no 21.1.13 released).
5057
// TODO: update temp fix - only working in 21.1.11 without errors
@@ -229,11 +236,12 @@ export class PackageManager {
229236
// tslint:disable-next-line:object-literal-sort-keys
230237
Util.execSync(`npm whoami --registry=${fullPackageRegistry}`, { stdio: "pipe", encoding: "utf8" });
231238
} catch (error) {
239+
if (!REGISTRY_ATTEMPT_LOGIN) {
240+
Util.log(message, "gray");
241+
return true;
242+
}
243+
232244
// try registering the user:
233-
Util.log(
234-
"The project you've created requires the full version of Ignite UI from Infragistics private feed.",
235-
"gray"
236-
);
237245
Util.log(
238246
"We are initiating the login process for you. This will be required only once per environment.",
239247
"gray"

packages/core/update/Update.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export async function updateWorkspace(rootPath: string): Promise<boolean> {
5555
}
5656
const pkgJSON = JSON.parse(fileString);
5757

58-
const errorMsg = "Something went wrong, please follow the steps in this guide: " + guideLink;
58+
const errorMsg = "Can't detect/setup Infragistics feed login required for licensed packages.\nSee: " + guideLink;
5959
if (!PackageManager.ensureRegistryUser(config, errorMsg)) {
6060
return false;
6161
}

spec/unit/packageManager-spec.ts

Lines changed: 63 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import child_process from "child_process";
22
import path from "path";
3-
import { App, Config, IFileSystem, PackageManager, ProjectConfig, Util } from "@igniteui/cli-core";
3+
import { App, Config, IFileSystem, PackageManager, ProjectConfig, REGISTRY_ATTEMPT_LOGIN, Util } from "@igniteui/cli-core";
44
import { resetSpy } from "../helpers/utils";
55

6+
const loginFlow = REGISTRY_ATTEMPT_LOGIN;
7+
68
describe("Unit - Package Manager", () => {
79
it("ensureIgniteUISource - Should run through properly when install now is set to true", async () => {
810
const mockRequire = {
@@ -48,32 +50,34 @@ describe("Unit - Package Manager", () => {
4850
spyOn(Util, "log");
4951
spyOn(PackageManager, "removePackage");
5052
await PackageManager.ensureIgniteUISource(true, mockTemplateMgr, true);
51-
expect(Util.log).toHaveBeenCalledTimes(4);
53+
expect(Util.log).toHaveBeenCalledTimes(loginFlow ? 4 : 2);
5254
expect(Util.log).toHaveBeenCalledWith(
5355
"The project you've created requires the full version of Ignite UI from Infragistics private feed.",
5456
"gray"
5557
);
56-
expect(Util.log).toHaveBeenCalledWith(
57-
"We are initiating the login process for you. This will be required only once per environment.",
58-
"gray"
59-
);
60-
expect(Util.log).toHaveBeenCalledWith(
61-
"Adding a registry user account for trial",
62-
"yellow"
63-
);
64-
expect(Util.log).toHaveBeenCalledWith(
65-
`Use your Infragistics account credentials. "@" is not supported, ` +
66-
`use "!!", so "username@infragistics.com" should be entered as "username!!infragistics.com"`,
67-
"yellow"
68-
);
69-
expect(path.join).toHaveBeenCalled();
70-
expect(Util.execSync).toHaveBeenCalledWith(
71-
"npm login --registry=trial --scope=@infragistics --auth-type=legacy",
72-
{
73-
stdio: "inherit"
74-
}
75-
);
76-
expect(Util.execSync).toHaveBeenCalledWith("npm config set @infragistics:registry trial");
58+
if (loginFlow) {
59+
expect(Util.log).toHaveBeenCalledWith(
60+
"We are initiating the login process for you. This will be required only once per environment.",
61+
"gray"
62+
);
63+
expect(Util.log).toHaveBeenCalledWith(
64+
"Adding a registry user account for trial",
65+
"yellow"
66+
);
67+
expect(Util.log).toHaveBeenCalledWith(
68+
`Use your Infragistics account credentials. "@" is not supported, ` +
69+
`use "!!", so "username@infragistics.com" should be entered as "username!!infragistics.com"`,
70+
"yellow"
71+
);
72+
expect(path.join).toHaveBeenCalled();
73+
expect(Util.execSync).toHaveBeenCalledWith(
74+
"npm login --registry=trial --scope=@infragistics --auth-type=legacy",
75+
{
76+
stdio: "inherit"
77+
}
78+
);
79+
expect(Util.execSync).toHaveBeenCalledWith("npm config set @infragistics:registry trial");
80+
}
7781
expect(PackageManager.removePackage).toHaveBeenCalled();
7882
expect(PackageManager.addPackage).toHaveBeenCalledWith(`@infragistics/ignite-ui-full@"20.1"`, true);
7983
});
@@ -112,46 +116,49 @@ describe("Unit - Package Manager", () => {
112116
spyOn(TestPackageManager, "getPackageJSON").and.callFake(() => mockRequire);
113117
await TestPackageManager.ensureIgniteUISource(true, mockTemplateMgr, true);
114118
expect(ProjectConfig.localConfig).toHaveBeenCalled();
115-
expect(Util.log).toHaveBeenCalledTimes(12);
119+
expect(Util.log).toHaveBeenCalledTimes(loginFlow ? 12 /* [O.O] */: 2);
116120
expect(Util.log).toHaveBeenCalledWith(
117121
"The project you've created requires the full version of Ignite UI from Infragistics private feed.",
118122
"gray"
119-
); // x2
120-
expect(Util.log).toHaveBeenCalledWith(
121-
"We are initiating the login process for you. This will be required only once per environment.",
122-
"gray"
123-
); // x2
124-
expect(Util.log).toHaveBeenCalledWith(
125-
"Adding a registry user account for trial",
126-
"yellow"
127-
); // x2
128-
expect(Util.log).toHaveBeenCalledWith(
129-
`Use your Infragistics account credentials. "@" is not supported, ` +
130-
`use "!!", so "username@infragistics.com" should be entered as "username!!infragistics.com"`,
131-
"yellow"
132-
); // x2
123+
);
133124
expect(Util.log).toHaveBeenCalledWith(
134125
"Something went wrong, " +
135126
"please follow the steps in this guide: https://www.igniteui.com/help/using-ignite-ui-npm-packages",
136-
"red"
137-
); // x2
138-
expect(Util.log).toHaveBeenCalledWith(
139-
"Something went wrong with upgrading Ignite UI to the full version. " +
140-
`As a result only views using OSS components will run correctly.`,
141-
"yellow"
142-
); // x1
143-
expect(Util.log).toHaveBeenCalledWith(
144-
"Please visit https://www.igniteui.com/help/using-ignite-ui-npm-packages " +
145-
`for instructions on how to install the full package.`,
146-
"yellow"
147-
); // x1
148-
expect(Util.execSync).toHaveBeenCalledWith(
149-
"npm login --registry=trial --scope=@infragistics --auth-type=legacy",
150-
{
151-
stdio: "inherit"
152-
}
127+
loginFlow ? "red": "gray"
153128
);
154-
expect(Util.execSync).toHaveBeenCalledTimes(4 /* ¯\(°_o)/¯*/);
129+
130+
if (loginFlow) {
131+
expect(Util.log).toHaveBeenCalledWith(
132+
"We are initiating the login process for you. This will be required only once per environment.",
133+
"gray"
134+
);
135+
expect(Util.log).toHaveBeenCalledWith(
136+
"Adding a registry user account for trial",
137+
"yellow"
138+
);
139+
expect(Util.log).toHaveBeenCalledWith(
140+
`Use your Infragistics account credentials. "@" is not supported, ` +
141+
`use "!!", so "username@infragistics.com" should be entered as "username!!infragistics.com"`,
142+
"yellow"
143+
);
144+
expect(Util.log).toHaveBeenCalledWith(
145+
"Something went wrong with upgrading Ignite UI to the full version. " +
146+
`As a result only views using OSS components will run correctly.`,
147+
"yellow"
148+
);
149+
expect(Util.log).toHaveBeenCalledWith(
150+
"Please visit https://www.igniteui.com/help/using-ignite-ui-npm-packages " +
151+
`for instructions on how to install the full package.`,
152+
"yellow"
153+
);
154+
expect(Util.execSync).toHaveBeenCalledWith(
155+
"npm login --registry=trial --scope=@infragistics --auth-type=legacy",
156+
{
157+
stdio: "inherit"
158+
}
159+
);
160+
}
161+
expect(Util.execSync).toHaveBeenCalledTimes(loginFlow ? 4 /* ¯\(°_o)/¯ */ : 1);
155162
expect(Util.execSync).toHaveBeenCalledWith(`npm whoami --registry=trial`, { stdio: "pipe", encoding: "utf8" });
156163
});
157164
it("ensureIgniteUISource - Should run through properly when install now is set to false", async () => {

0 commit comments

Comments
 (0)