Skip to content

Commit

Permalink
Merge branch 'develop' into new_branch
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitpatilok authored Oct 18, 2024
2 parents acd9087 + db1e3b2 commit 5753eac
Show file tree
Hide file tree
Showing 43 changed files with 1,645 additions and 1,027 deletions.
35 changes: 9 additions & 26 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ jobs:
csc_link_secret: DESIGNER_MAC_CSC_LINK
csc_key_password_secret: DESIGNER_MAC_CSC_KEY_PASSWORD
- os: windows-latest
csc_link_secret: DESIGNER_WINDOWS_CSC_LINK
csc_key_password_secret: DESIGNER_WINDOWS_CSC_KEY_PASSWORD
csc_link_secret: ''
csc_key_password_secret: ''
- os: ubuntu-latest
csc_link_secret: ''
csc_key_password_secret: ''
Expand Down Expand Up @@ -132,32 +132,15 @@ jobs:
- name: Package dist app (Windows only)
if: matrix.os == 'windows-latest'
shell: bash
run: NODE_OPTIONS='--max_old_space_size=6144' npm run package:windows:dist -w insomnia


- name: Setup Insomnia version env var (Windows only)
if: matrix.os == 'windows-latest'
shell: pwsh # Use PowerShell shell
run: |
$insomniaVersion = jq -r '.version' "./packages/insomnia/package.json"
$insoVersion = jq -r '.version' "./packages/insomnia-inso/package.json"
echo "INSOMNIA_VERSION=$insomniaVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "INSO_VERSION=$insoVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# code-signs the windows installer
- name: Code-sign Windows Installer artifact (Windows only)
if: matrix.os == 'windows-latest'
uses: sslcom/esigner-codesign@develop
with:
command: sign
username: ${{secrets.ES_USERNAME}}
password: ${{secrets.ES_PASSWORD}}
credential_id: ${{secrets.ES_CREDENTIAL_ID}}
totp_secret: ${{secrets.ES_TOTP_SECRET}}
file_path: ${{ env.CODESIGN_FILE_PATH}}
override: true
docker pull ghcr.io/sslcom/codesigner-win:latest
NODE_OPTIONS='--max_old_space_size=6144' npm run package:windows:dist -w insomnia
env:
CODESIGN_FILE_PATH: packages/insomnia/dist/squirrel-windows/Insomnia.Core-${{ env.INSOMNIA_VERSION }}.exe
USERNAME: ${{secrets.ES_USERNAME}}
PASSWORD: ${{secrets.ES_PASSWORD}}
CREDENTIAL_ID: ${{secrets.ES_CREDENTIAL_ID}}
TOTP_SECRET: ${{secrets.ES_TOTP_SECRET}}


- name: Package inso
run: |
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/insomnia-inso/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "insomnia-inso",
"version": "10.1.0-beta.2",
"version": "10.1.0",
"homepage": "https://insomnia.rest",
"description": "A CLI for Insomnia - The Collaborative API Design Tool",
"author": "Kong <office@konghq.com>",
Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "insomnia-sdk",
"version": "10.1.0-beta.2",
"version": "10.1.0",
"description": "",
"main": "src/objects/index.ts",
"types": "src/objects/index.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia-smoke-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"bugs": {
"url": "https://github.com/kong/insomnia/issues"
},
"version": "10.1.0-beta.2",
"version": "10.1.0",
"scripts": {
"test:dev": "xvfb-maybe cross-env BUNDLE=dev playwright test",
"test:build": "xvfb-maybe cross-env BUNDLE=build playwright test",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ test('can send request with custom ca root certificate', async ({ app, page }) =
await page.getByLabel('Request Collection').getByTestId('sends request with certs').press('Enter');

await page.getByRole('button', { name: 'Send', exact: true }).click();
await page.getByRole('button', { name: 'Ok', exact: true }).click();
await page.getByText('Error: SSL peer certificate or SSH remote key was not OK').click();

const fixturePath = getFixturePath('certificates');
Expand Down
1 change: 0 additions & 1 deletion packages/insomnia-smoke-test/tests/smoke/app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,5 @@ test('can cancel requests', async ({ app, page }) => {
await page.getByTestId('request-pane').getByRole('button', { name: 'Send' }).click();

await page.getByRole('button', { name: 'Cancel Request' }).click();
await page.getByRole('button', { name: 'Ok', exact: true }).click();
await page.click('text=Request was cancelled');
});
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ test.describe('Environment Editor', async () => {
await page.getByText('baseenv1').click();
});

test('duplicate an environment', async ({ page }) => {
await page.getByRole('button', { name: 'Manage Environments' }).click();
await page.getByRole('button', { name: 'Manage collection environments' }).click();
await page.getByRole('row', { name: 'ExampleA' }).getByLabel('Environment Actions').click();
await page.getByText('Duplicate').click();
await page.getByLabel('Environments', { exact: true }).getByText('ExampleA (Copy)').click();
});

// rename an existing environment
test('Rename an existing environment', async ({ page }) => {
// Rename the environment
Expand Down
31 changes: 16 additions & 15 deletions packages/insomnia-smoke-test/tests/smoke/git-interactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,11 @@ test('Git Interactions (clone, checkout branch, pull, push, stage changes, ...)'
await page.waitForTimeout(1000);
await page.getByTestId('git-dropdown').click();
await page.getByText('Commit').click();
await page.getByText('Modified Objects').click();
await page.getByText('ApiSpec').click();
await page.getByPlaceholder('A descriptive message to').click();
await page.getByPlaceholder('A descriptive message to').fill('example commit message');
await page.getByRole('dialog').getByText('abc').click();
await page.getByRole('button', { name: ' Commit' }).click();
await page.getByText('No changes to commit.').click();
await page.getByRole('button', { name: 'Close' }).click();
await page.getByRole('row', { name: 'spec.yaml' }).click();
await page.locator('button[name="Stage all changes"]').click();
await page.getByPlaceholder('This is a helpful message').click();
await page.getByPlaceholder('This is a helpful message').fill('example commit message');
await page.getByRole('button', { name: 'Commit', exact: true }).click();

// switch back to main branch, which should not have said changes
await page.getByTestId('git-dropdown').click();
Expand Down Expand Up @@ -93,17 +90,21 @@ test('Git Interactions (clone, checkout branch, pull, push, stage changes, ...)'
await page.getByLabel('Name', { exact: true }).fill(`My Folder ${testUUID}`);
await page.getByRole('button', { name: 'Create', exact: true }).click();
await page.getByTestId('git-dropdown').click();

// Commit changes
await page.getByText('Commit').click();
await page.getByRole('cell', { name: `My Folder ${testUUID}` }).locator('label').click();
await page.getByPlaceholder('A descriptive message to').click();
await page.getByPlaceholder('A descriptive message to').fill(`commit test ${testUUID}`);
await page.getByText('Commit Changes').click();
await page.getByRole('button', { name: 'Commit' }).click();
await page.getByText('No changes to commit.').click();
await page.getByRole('button', { name: 'Close' }).click();
await page.getByRole('row', { name: `My Folder ${testUUID}`, exact: true }).click();
await page.locator('button[name="Stage all changes"]').click();
await page.getByPlaceholder('This is a helpful message').click();
await page.getByPlaceholder('This is a helpful message').fill(`commit test ${testUUID}`);
await page.getByRole('button', { name: 'Commit', exact: true }).click();

// Push changes
await page.getByTestId('git-dropdown').click();
await page.getByText('Push', { exact: true }).click();
await page.getByTestId('git-dropdown').click();

// Check if the changes are pushed
await page.getByText('Fetch').click();
await page.getByTestId('git-dropdown').click();
await page.getByText('History').click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,6 @@ test.describe('pre-request features tests', async () => {
// send
await page.getByTestId('request-pane').getByRole('button', { name: 'Send' }).click();

// close the alert modal
await page.getByRole('code').getByText('Error: Couldn\'t connect to').click();
await page.getByRole('button', { name: 'Ok', exact: true }).click();

// verify
await page.getByRole('tab', { name: 'Console' }).click();
await expect(responsePane).toContainText('localhost:2222'); // original proxy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ test.describe('test hidden window handling', async () => {

await page.getByRole('button', { name: 'Cancel Request' }).click();

// check the alert model message
await page.getByRole('code').getByText('Request was cancelled').click();
await page.getByRole('button', { name: 'Ok', exact: true }).click();
// check the response pane message
await page.click('text=Request was cancelled');
});
Expand All @@ -54,8 +51,7 @@ test.describe('test hidden window handling', async () => {
await page.getByLabel('Request Collection').getByTestId('Long running task - post').press('Enter');
await page.getByTestId('request-pane').getByRole('button', { name: 'Send', exact: true }).click();

await page.getByRole('code').getByText('Executing script timeout').click();
await page.getByRole('button', { name: 'Ok', exact: true }).click();
await page.getByText('Executing script timeout').click();
await page.getByRole('tab', { name: 'Console' }).click();
await page.getByRole('tab', { name: 'Preview' }).click();

Expand Down Expand Up @@ -98,8 +94,7 @@ test.describe('test hidden window handling', async () => {
await page.getByTestId('request-pane').getByRole('button', { name: 'Send', exact: true }).click();
// await page.getByText('Timeout: Hidden browser window is not responding').click();

await page.getByRole('code').getByText('Executing script timeout').click();
await page.getByRole('button', { name: 'Ok', exact: true }).click();
await page.getByText('Executing script timeout').click();

// send the another script with normal script
await page.getByLabel('Request Collection').getByTestId('simple log').press('Enter');
Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia-testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": true,
"name": "insomnia-testing",
"license": "Apache-2.0",
"version": "10.1.0-beta.2",
"version": "10.1.0",
"author": "Kong <office@konghq.com>",
"repository": {
"type": "git",
Expand Down
59 changes: 59 additions & 0 deletions packages/insomnia/customSign.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
const { exec } = require('child_process');
const util = require('util');
const path = require('path');
const execAsync = util.promisify(exec);

// adapted from https://www.electron.build/win.html#how-do-delegate-code-signing
// It was possible code-sign installer after packaging, but some files are only available
// through hooking into the signing step of electron-builder while the final squirrel installer is being built
// This makes it possible to sign the Update.exe and stub of Insomnia.exe that end up in C:\Users\<user>\AppData\Local\insomnia
exports.default = async function(configuration) {
// skip signing if not windows squirrel
if (configuration.options.target.length === 0 || configuration.options.target[0].target !== 'squirrel') {
console.log('[customSign] Skipping signing because target is not windows squirrel.');
return;
}

const { USERNAME, PASSWORD, CREDENTIAL_ID, TOTP_SECRET } = process.env;
if (!USERNAME || !PASSWORD || !CREDENTIAL_ID || !TOTP_SECRET) {
console.log('[customSign] Skipping signing, Missing required environment variables.');
return;
}

// Note: Avoid changing the lines bellow. Risk of breaking the windows code-signing process.
// Feedback loop > 15 mins. Requires a branch on origin, a PR, and a separate dummy release pipeline to test changes.
// sslcom/codesigner-win has large image size (>1GB) and requires docker within windows-latest host.
const rawPath = configuration.path.replace(/(\r\n|\n|\r)/gm, ''); // remove /n and other crap from path
console.log('[customSign] File to sign before final packaging:', rawPath);
const absolutePath = path.resolve(rawPath); // C:\Users\...\Update.exe
const fixedAbsolutePath = absolutePath.replace(/\\/g, '/'); // C:/Users/.../Update.exe
const lastSlashIndex = fixedAbsolutePath.lastIndexOf('/'); // index of last / slash
const directoryPath = fixedAbsolutePath.substring(0, lastSlashIndex); // C:/Users/...
const inputFileName = path.basename(absolutePath); // Update.exe
const codeSignPath = 'C:/CodeSignTool/Insomnia'; // path inside docker container
const dockerInputFilePath = path.join(codeSignPath, inputFileName); // C:/CodeSignTool/Insomnia/Update.exe
const dockerCommand = `docker run --rm \
-v "${directoryPath}:${codeSignPath}" \
-e USERNAME="${USERNAME}" \
-e PASSWORD="${PASSWORD}" \
-e CREDENTIAL_ID="${CREDENTIAL_ID}" \
-e TOTP_SECRET="${TOTP_SECRET}" \
ghcr.io/sslcom/codesigner-win:latest sign \
\`\`-input_file_path="${dockerInputFilePath}" \`\`-override`;

try {
console.log('[customSign] Docker command:', dockerCommand);
console.log('[customSign] Starting to run sign cmd via docker...');
const { stdout, stderr } = await execAsync(dockerCommand);

console.log('[customSign] Docker command output:', stdout);
if (stderr) {
console.error('[customSign] Docker command error output:', stderr);
}

console.log('[customSign] File signed successfully.');
} catch (error) {
console.error('[customSign] Error executing Docker command:', error);
throw error;
}
};
2 changes: 2 additions & 0 deletions packages/insomnia/electron-builder.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ const config = {
target: 'squirrel',
},
],
sign: './customSign.js',
signingHashAlgorithms: ['sha256'], // avoid duplicate signing hook calls https://github.com/electron-userland/electron-builder/issues/3995#issuecomment-505725704
},
squirrelWindows: {
artifactName: `${BINARY_PREFIX}-\${version}.\${ext}`,
Expand Down
4 changes: 2 additions & 2 deletions packages/insomnia/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "insomnia",
"version": "10.1.0-beta.2",
"version": "10.1.0",
"productName": "Insomnia",
"private": true,
"description": "The Collaborative API Design Tool",
Expand All @@ -23,7 +23,7 @@
"lint": "eslint . --ext .js,.ts,.tsx --cache",
"package": "npm run build:app && cross-env USE_HARD_LINKS=false electron-builder build --config electron-builder.config.js",
"package:windows:unpacked": "npm run build:app && cross-env USE_HARD_LINKS=false electron-builder build --config electron-builder.config.js --dir",
"package:windows:dist": "cross-env USE_HARD_LINKS=false electron-builder build --config electron-builder.config.js --prepackaged ./dist/win-unpacked",
"package:windows:dist": "cross-env USE_HARD_LINKS=false electron-builder build --config electron-builder.config.js --win squirrel --prepackaged ./dist/win-unpacked",
"start": "npx -y concurrently -n browser,main --kill-others \"npm run start:dev-server\" \"npm run start:electron\"",
"start:dev-server": "vite dev",
"start:electron": "cross-env NODE_ENV=development esr esbuild.main.ts && electron --inspect=5858 .",
Expand Down
Loading

0 comments on commit 5753eac

Please sign in to comment.