mirror of
https://github.com/Kong/insomnia.git
synced 2026-04-21 22:57:59 -04:00
Allow specifying a custom version for Inso (#4086)
This commit is contained in:
32
.github/workflows/test.yml
vendored
32
.github/workflows/test.yml
vendored
@@ -11,7 +11,22 @@ on:
|
||||
- synchronize
|
||||
|
||||
jobs:
|
||||
get_version:
|
||||
name: Get version
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
inso-version: ${{ steps.get-package-version.outputs.current-version }}
|
||||
steps:
|
||||
- name: Checkout branch
|
||||
uses: actions/checkout@v1
|
||||
- name: Get version
|
||||
id: get-package-version
|
||||
uses: martinbeentjes/npm-get-version-action@master
|
||||
with:
|
||||
path: packages/insomnia-inso
|
||||
|
||||
OS:
|
||||
needs: [ get_version ]
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -42,18 +57,22 @@ jobs:
|
||||
- name: Run tests
|
||||
run: npm test
|
||||
|
||||
- name: Package Inso CLI
|
||||
run: npm run inso-package
|
||||
|
||||
- name: Set Inso Variables
|
||||
id: inso-variables
|
||||
shell: bash
|
||||
run: |
|
||||
PKG_NAME="${{ matrix.os }}-inso-${{ github.run_number }}"
|
||||
INSO_VERSION="${{ needs.get_version.outputs.inso-version }}-run.${{ github.run_number }}"
|
||||
PKG_NAME="inso-${{ matrix.os }}-$INSO_VERSION"
|
||||
BUNDLE_ID="com.insomnia.inso.app"
|
||||
|
||||
echo ::set-output name=pkg-name::$PKG_NAME
|
||||
echo ::set-output name=bundle-id::$BUNDLE_ID
|
||||
echo ::set-output name=inso-version::$INSO_VERSION
|
||||
|
||||
- name: Package Inso CLI
|
||||
run: npm run inso-package
|
||||
env:
|
||||
VERSION: ${{ steps.inso-variables.outputs.inso-version }}
|
||||
|
||||
- name: Create macOS installer package
|
||||
if: matrix.os == 'macos-latest'
|
||||
@@ -69,8 +88,7 @@ jobs:
|
||||
PKG_NAME: ${{ steps.inso-variables.outputs.pkg-name }}
|
||||
BUNDLE_ID: ${{ steps.inso-variables.outputs.bundle-id }}
|
||||
ARTIFACT_LOCATION: compressed
|
||||
# Hardcoded here, configured in https://github.com/Kong/insomnia/pull/4086
|
||||
VERSION: "2.3.2"
|
||||
VERSION: ${{ steps.inso-variables.outputs.inso-version }}
|
||||
|
||||
# We don't need to notarize and staple on every commit
|
||||
# - name: Notarize installer package
|
||||
@@ -90,6 +108,8 @@ jobs:
|
||||
|
||||
- name: Create Inso CLI artifacts
|
||||
run: npm run inso-package:compress
|
||||
env:
|
||||
VERSION: ${{ steps.inso-variables.outputs.inso-version }}
|
||||
|
||||
- name: Upload Inso CLI artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
|
||||
@@ -66,15 +66,6 @@ describe('cli', () => {
|
||||
logger.restoreAll();
|
||||
});
|
||||
|
||||
it.each(['-v', '--version'])('inso %s should print "dev" if running in development', args => {
|
||||
const oldNodeEnv = process.env.NODE_ENV;
|
||||
process.env.NODE_ENV = 'development';
|
||||
logger.wrapAll();
|
||||
expect(() => inso(args)).toThrowError('dev');
|
||||
logger.restoreAll();
|
||||
process.env.NODE_ENV = oldNodeEnv;
|
||||
});
|
||||
|
||||
it('should print options', () => {
|
||||
inso('generate config file.yaml -t declarative --printOptions --verbose');
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as packageJson from '../package.json';
|
||||
import { InsoError } from './errors';
|
||||
import { globalBeforeAll, globalBeforeEach } from './jest/before';
|
||||
import { logger } from './logger';
|
||||
import { exit, getDefaultAppName, getVersion, isDevelopment, logErrorExit1, noop } from './util';
|
||||
import { exit, getDefaultAppName, getVersion, logErrorExit1, noop } from './util';
|
||||
|
||||
describe('exit()', () => {
|
||||
beforeAll(() => {
|
||||
@@ -126,27 +126,11 @@ describe('getVersion()', () => {
|
||||
expect(getVersion()).toBe(packageJson.version);
|
||||
});
|
||||
|
||||
it('should return dev if running in development', () => {
|
||||
const oldNodeEnv = process.env.NODE_ENV;
|
||||
process.env.NODE_ENV = 'development';
|
||||
expect(getVersion()).toBe('dev');
|
||||
process.env.NODE_ENV = oldNodeEnv;
|
||||
});
|
||||
});
|
||||
|
||||
describe('isDevelopment()', () => {
|
||||
it('should return true if NODE_ENV is development', () => {
|
||||
const oldNodeEnv = process.env.NODE_ENV;
|
||||
process.env.NODE_ENV = 'development';
|
||||
expect(isDevelopment()).toBe(true);
|
||||
process.env.NODE_ENV = oldNodeEnv;
|
||||
});
|
||||
|
||||
it('should return false if NODE_ENV is not development', () => {
|
||||
const oldNodeEnv = process.env.NODE_ENV;
|
||||
process.env.NODE_ENV = 'production';
|
||||
expect(isDevelopment()).toBe(false);
|
||||
process.env.NODE_ENV = oldNodeEnv;
|
||||
it('should get version from env variable', () => {
|
||||
const oldVersion = process.env.VERSION;
|
||||
process.env.VERSION = '2.3.3-canary.1234';
|
||||
expect(getVersion()).toBe('2.3.3-canary.1234');
|
||||
process.env.VERSION = oldVersion;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -2,11 +2,7 @@ import packageJson from '../package.json';
|
||||
import { handleError } from './errors';
|
||||
|
||||
export const getVersion = () => {
|
||||
return isDevelopment() ? 'dev' : packageJson.version;
|
||||
};
|
||||
|
||||
export const isDevelopment = () => {
|
||||
return process.env.NODE_ENV === 'development';
|
||||
return process.env.VERSION || packageJson.version;
|
||||
};
|
||||
|
||||
export const logErrorExit1 = (err?: Error) => {
|
||||
|
||||
@@ -9,6 +9,7 @@ module.exports = merge(base, {
|
||||
new webpack.DefinePlugin({
|
||||
__DEV__: true,
|
||||
'process.env.DEFAULT_APP_NAME': JSON.stringify('insomnia-app'),
|
||||
'process.env.VERSION': JSON.stringify('dev'),
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
@@ -11,6 +11,7 @@ module.exports = merge(base, {
|
||||
plugins: [
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.DEFAULT_APP_NAME': JSON.stringify('Insomnia'),
|
||||
'process.env.VERSION': JSON.stringify(process.env.VERSION),
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user