Skip to content

Commit 90e0621

Browse files
committed
feat: Added ability to read codify test jwt from environment
1 parent 146df49 commit 90e0621

3 files changed

Lines changed: 12 additions & 18 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codify-plugin-test",
3-
"version": "0.0.52",
3+
"version": "0.0.53",
44
"description": "",
55
"main": "dist/index.js",
66
"typings": "dist/index.d.ts",
@@ -35,7 +35,7 @@
3535
"eslint-config-oclif-typescript": "^3",
3636
"eslint-config-prettier": "^9.0.0",
3737
"tsx": "^4.7.3",
38-
"typescript": "^5",
38+
"typescript": "5.3.3",
3939
"vitest": "^1.4.0",
4040
"codify-plugin-lib": "1.0.171"
4141
},

src/plugin-process.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ export class PluginProcess {
101101
this.childProcess.kill();
102102
}
103103

104-
private handleIncomingRequests(process: ChildProcess) {
104+
private handleIncomingRequests(cp: ChildProcess) {
105105
// Listen for incoming sudo incoming sudo requests
106-
process.on('message', async (message) => {
106+
cp.on('message', async (message) => {
107107
if (!ipcMessageValidator(message)) {
108108
throw new Error(`Invalid message from plugin. ${JSON.stringify(message, null, 2)}`);
109109
}
@@ -117,7 +117,7 @@ export class PluginProcess {
117117
const { command, options } = data as unknown as SudoRequestData;
118118
const result = await sudoSpawn(command, options);
119119

120-
process.send(<IpcMessageV2>{
120+
cp.send(<IpcMessageV2>{
121121
cmd: MessageCmd.SUDO_REQUEST + '_Response',
122122
data: result,
123123
requestId,
@@ -130,7 +130,7 @@ export class PluginProcess {
130130
throw new Error(`Invalid sudo request from plugin. ${JSON.stringify(sudoRequestValidator.errors, null, 2)}`);
131131
}
132132

133-
process.send(<IpcMessageV2>{
133+
cp.send(<IpcMessageV2>{
134134
cmd: MessageCmd.PRESS_KEY_TO_CONTINUE_REQUEST + '_Response',
135135
data: {},
136136
requestId,
@@ -140,19 +140,14 @@ export class PluginProcess {
140140
if (message.cmd === MessageCmd.CODIFY_CREDENTIALS_REQUEST) {
141141
const { requestId } = message;
142142

143-
const loginJson = await fs.readFile(path.join(os.homedir(), '.codify', 'credentials.json'), 'utf8');
144-
if (!loginJson) {
145-
throw new Error('Unable to get login credentials')
143+
const testJwt = process.env.VITE_CODIFY_TEST_JWT;
144+
if (!testJwt) {
145+
throw new Error('Unable to parse login credentials from VITE_CODIFY_TEST_JWT env var. Please set and try again');
146146
}
147147

148-
const login = JSON.parse(loginJson);
149-
if (!login) {
150-
throw new Error('Unable to parse login credentials')
151-
}
152-
153-
process.send(<IpcMessageV2>{
148+
cp.send(<IpcMessageV2>{
154149
cmd: MessageCmd.CODIFY_CREDENTIALS_REQUEST + '_Response',
155-
data: login.accessToken,
150+
data: testJwt,
156151
requestId,
157152
})
158153
}

tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
"resolveJsonModule": true,
88
"alwaysStrict": true,
99
"noImplicitAny": true,
10-
"removeComments": true,
1110
"strictNullChecks": true,
1211
"declaration": true,
1312
"emitDecoratorMetadata": true,
1413
"experimentalDecorators": true,
1514
"rootDir": "src",
16-
"outDir": "./dist"
15+
"outDir": "./dist",
1716
},
1817
"exclude": [
1918
"node_modules",

0 commit comments

Comments
 (0)