|
1 | 1 | import child_process from "child_process"; |
2 | 2 | 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"; |
4 | 4 | import { resetSpy } from "../helpers/utils"; |
5 | 5 |
|
| 6 | +const loginFlow = REGISTRY_ATTEMPT_LOGIN; |
| 7 | + |
6 | 8 | describe("Unit - Package Manager", () => { |
7 | 9 | it("ensureIgniteUISource - Should run through properly when install now is set to true", async () => { |
8 | 10 | const mockRequire = { |
@@ -48,32 +50,34 @@ describe("Unit - Package Manager", () => { |
48 | 50 | spyOn(Util, "log"); |
49 | 51 | spyOn(PackageManager, "removePackage"); |
50 | 52 | await PackageManager.ensureIgniteUISource(true, mockTemplateMgr, true); |
51 | | - expect(Util.log).toHaveBeenCalledTimes(4); |
| 53 | + expect(Util.log).toHaveBeenCalledTimes(loginFlow ? 4 : 2); |
52 | 54 | expect(Util.log).toHaveBeenCalledWith( |
53 | 55 | "The project you've created requires the full version of Ignite UI from Infragistics private feed.", |
54 | 56 | "gray" |
55 | 57 | ); |
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 | + } |
77 | 81 | expect(PackageManager.removePackage).toHaveBeenCalled(); |
78 | 82 | expect(PackageManager.addPackage).toHaveBeenCalledWith(`@infragistics/ignite-ui-full@"20.1"`, true); |
79 | 83 | }); |
@@ -112,46 +116,49 @@ describe("Unit - Package Manager", () => { |
112 | 116 | spyOn(TestPackageManager, "getPackageJSON").and.callFake(() => mockRequire); |
113 | 117 | await TestPackageManager.ensureIgniteUISource(true, mockTemplateMgr, true); |
114 | 118 | expect(ProjectConfig.localConfig).toHaveBeenCalled(); |
115 | | - expect(Util.log).toHaveBeenCalledTimes(12); |
| 119 | + expect(Util.log).toHaveBeenCalledTimes(loginFlow ? 12 /* [O.O] */: 2); |
116 | 120 | expect(Util.log).toHaveBeenCalledWith( |
117 | 121 | "The project you've created requires the full version of Ignite UI from Infragistics private feed.", |
118 | 122 | "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 | + ); |
133 | 124 | expect(Util.log).toHaveBeenCalledWith( |
134 | 125 | "Something went wrong, " + |
135 | 126 | "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" |
153 | 128 | ); |
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); |
155 | 162 | expect(Util.execSync).toHaveBeenCalledWith(`npm whoami --registry=trial`, { stdio: "pipe", encoding: "utf8" }); |
156 | 163 | }); |
157 | 164 | it("ensureIgniteUISource - Should run through properly when install now is set to false", async () => { |
|
0 commit comments