Skip to content
This repository has been archived by the owner on Jul 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #163 from crishellco/cm/instance-id
Browse files Browse the repository at this point in the history
Add Instance ID Support
  • Loading branch information
crishellco authored Jul 3, 2021
2 parents 7b673ed + 67fe536 commit 94e8b42
Show file tree
Hide file tree
Showing 13 changed files with 2,902 additions and 2,561 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: Build
on: push

jobs:
deploy:
build:
runs-on: ubuntu-latest

strategy:
Expand All @@ -24,3 +24,4 @@ jobs:
- run: yarn test
env:
CI: true
- uses: codecov/codecov-action@v1
43 changes: 43 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Publish

on:
workflow_run:
workflows: ["Build"]
branches:
- master
types:
- completed

jobs:
publish:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}

strategy:
matrix:
node-version: [12.x]

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: yarn
- run: yarn build
- id: publish
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
- name: Create Release
if: steps.publish.outputs.type != 'none'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.publish.outputs.version }}
release_name: Release ${{ steps.publish.outputs.version }}
body: ${{ steps.publish.outputs.version }}
draft: false
prerelease: false
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Vue Unleash

![Build](https://github.com/crishellco/vue-unleash/workflows/Build/badge.svg)
![](badges/badge-branches.svg)
![](badges/badge-functionss.svg)
![](badges/badge-lines.svg)
![](badges/badge-statements.svg)
[![codecov](https://codecov.io/gh/crishellco/vue-unleash/branch/master/graph/badge.svg?token=KSe1Aim7Mx)](https://codecov.io/gh/crishellco/vue-unleash)
[![Maintainability](https://api.codeclimate.com/v1/badges/2a6e74587ac474c5f0d5/maintainability)](https://codeclimate.com/github/crishellco/vue-unleash/maintainability)

A Vue plugin for [Unleash](https://unleash.github.io/).
Expand Down Expand Up @@ -38,6 +35,9 @@ Vue.use(VueUnleash, {
// Optional, name of app
appName: 'MyVueApp',

// Optional, instance id of app
instanceId: 'my-vue-app-1',

// Required, Unleash instance host
host: 'https://my-hosted-unleash.io',

Expand Down
1 change: 0 additions & 1 deletion badges/badge-branches.svg

This file was deleted.

1 change: 0 additions & 1 deletion badges/badge-functions.svg

This file was deleted.

1 change: 0 additions & 1 deletion badges/badge-lines.svg

This file was deleted.

1 change: 0 additions & 1 deletion badges/badge-statements.svg

This file was deleted.

15 changes: 4 additions & 11 deletions dist/index.js

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-unleash",
"version": "1.1.0",
"version": "1.2.0",
"author": "Chris Mitchell (@crishellco)",
"description": "A Vue plugin for the Unleash open-source feature flag platform",
"main": "dist/index.js",
Expand All @@ -9,7 +9,7 @@
"src"
],
"scripts": {
"test": "jest && jest-coverage-badges output badges",
"test": "jest",
"lint": "eslint --ext .js,.vue src/",
"lint:fix": "eslint --ext .js,.vue src/ --fix",
"build": "cross-env NODE_ENV=production webpack --config webpack.config.js"
Expand Down Expand Up @@ -44,7 +44,6 @@
"eslint-plugin-vue": "^6.0.1",
"husky": "^4.2.3",
"jest": "^24.9.0",
"jest-coverage-badges": "^1.1.2",
"lodash.keyby": "^4.6.0",
"poi": "^12.7.1",
"prettier": "^1.19.1",
Expand All @@ -64,4 +63,4 @@
"vue": "^2.6.10",
"vuex": "^3.1.2"
}
}
}
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { moduleFactory } from './module';
import UnleashFeature from './UnleashFeature.vue';

const install = (Vue, { appName, namePrefix, host, strategyProviders, store }) => {
const install = (Vue, { appName, instanceId, namePrefix, host, strategyProviders, store }) => {
if (!host) {
throw new Error('Please initialize plugin with a Unleash host.');
}
Expand All @@ -11,7 +11,10 @@ const install = (Vue, { appName, namePrefix, host, strategyProviders, store }) =
}

Vue.config.applicationHostname = 'localhost';
store.registerModule('unleash', moduleFactory({ host, appName, namePrefix, strategyProviders }));
store.registerModule(
'unleash',
moduleFactory({ host, appName, instanceId, namePrefix, strategyProviders })
);
Vue.component('unleash-feature', UnleashFeature);
store.dispatch('unleash/fetch');
};
Expand Down
5 changes: 3 additions & 2 deletions src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from 'axios';
import keyBy from 'lodash.keyby';
import Vue from 'vue';

const moduleFactory = ({ host, appName, namePrefix, strategyProviders = {} }) => ({
const moduleFactory = ({ host, appName, instanceId, namePrefix, strategyProviders = {} }) => ({
actions: {
async fetch({ commit }) {
commit('setLoading', true);
Expand All @@ -12,7 +12,8 @@ const moduleFactory = ({ host, appName, namePrefix, strategyProviders = {} }) =>
`${host}/api/client/features${namePrefix ? `?namePrefix=${namePrefix}` : ''}`,
{
headers: {
'UNLEASH-APPNAME': appName
'UNLEASH-APPNAME': appName,
'UNLEASH-INSTANCEID': instanceId
}
}
);
Expand Down
5 changes: 3 additions & 2 deletions test/plugin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import VueUnleash from '../src';
import axios from 'axios';

const appName = 'VueUnleash';
const instanceId = 'vue-unleash-1';
const component = {
template: '<unleash-feature name="Settings">hello</unleash-feature>'
};
Expand Down Expand Up @@ -72,7 +73,7 @@ describe('module.js', () => {
localVue = createLocalVue();
localVue.use(Vuex);
store = new Vuex.Store();
localVue.use(VueUnleash, { appName, host, strategyProviders, store });
localVue.use(VueUnleash, { appName, host, instanceId, strategyProviders, store });

wrapper = mount(component, { localVue, store });
});
Expand All @@ -95,7 +96,7 @@ describe('module.js', () => {
localVue = createLocalVue();
localVue.use(Vuex);
store = new Vuex.Store();
localVue.use(VueUnleash, { appName, host, namePrefix: 'namePrefix', store });
localVue.use(VueUnleash, { appName, host, instanceId, namePrefix: 'namePrefix', store });

wrapper = mount(component, { localVue, store });

Expand Down
Loading

0 comments on commit 94e8b42

Please sign in to comment.