Skip to content

Commit acf4b15

Browse files
committed
feat!: move package to @Workfront scope
BREAKING CHANGE: workfront-api is deprecated. use @workfront/api instead.
1 parent c5ada5c commit acf4b15

16 files changed

+13019
-7222
lines changed

.github/workflows/publish.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Publish
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
SEMVER_TYPE:
7+
description: 'Semver type'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
16+
jobs:
17+
publish-npm:
18+
environment: Public NPM registry
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: write
22+
id-token: write
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
ssh-key: ${{ secrets.DEPLOY_KEY }}
27+
- name: Check if on main branch
28+
run: |
29+
if [[ $GITHUB_REF != 'refs/heads/main' ]]; then
30+
echo "This workflow must run on the 'main' branch."
31+
exit 1
32+
fi
33+
- uses: actions/setup-node@v4
34+
with:
35+
node-version: 'lts/*'
36+
cache: 'npm'
37+
registry-url: 'https://registry.npmjs.org'
38+
scope: '@workfront'
39+
- run: npm ci --no-fund --no-audit
40+
- name: Bump package version
41+
run: |
42+
git config --global user.name 'github-actions[bot]'
43+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
44+
echo "Bumping version as ${{ github.event.inputs.SEMVER_TYPE }}"
45+
npm version --no-commit-hooks ${{ github.event.inputs.SEMVER_TYPE }}
46+
git push origin main --follow-tags
47+
- name: Publish to NPM
48+
run: npm publish --provenance --access public
49+
env:
50+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
- name: Draft release
53+
run: |
54+
VERSION=$(node -p "require('./package.json').version")
55+
gh release create v$VERSION --generate-notes --draft --verify-tag --fail-on-no-commits
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
VERSION: ${{ inputs.next_version }}
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
1-
name: Checks
1+
name: Verify
22

3-
on: [push]
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
workflow_dispatch:
411

512
jobs:
613
test-mocha:
714
runs-on: ubuntu-latest
815

916
strategy:
1017
matrix:
11-
node-version: [18.x, 20.x]
18+
node-version: [ 20.x, 22.x ]
1219

1320
steps:
1421
- uses: actions/checkout@v4
1522
name: Use Node.js ${{ matrix.node-version }}
1623
- uses: actions/setup-node@v4
1724
with:
1825
node-version: ${{ matrix.node-version }}
19-
- run: yarn install --frozen-lockfile
20-
- run: yarn run test:mocha
26+
cache: 'npm'
27+
registry-url: 'https://registry.npmjs.org'
28+
scope: '@workfront'
29+
- run: npm ci --no-audit --no-fund
30+
- run: npm run build
31+
- run: npm run test:mocha
2132

2233
test-karma:
2334
runs-on: ubuntu-latest
@@ -28,19 +39,24 @@ jobs:
2839

2940
steps:
3041
- uses: actions/checkout@v4
31-
name: Use latest Node.js version
42+
name: Use Node LTS version
3243
- uses: saucelabs/sauce-connect-action@v2
3344
with:
3445
username: ${{ secrets.SAUCE_USERNAME }}
3546
accessKey: ${{ secrets.SAUCE_ACCESS_KEY }}
3647
tunnelIdentifier: github-action-tunnel
3748
scVersion: 4.6.4
3849
- uses: actions/setup-node@v4
39-
- run: yarn install --frozen-lockfile
40-
- run: yarn run test:karma
50+
with:
51+
node-version: lts/*
52+
cache: 'npm'
53+
registry-url: 'https://registry.npmjs.org'
54+
scope: '@workfront'
55+
- run: npm ci --no-audit --no-fund
56+
- run: npm run build
57+
- run: npm run test:karma
4158
- uses: codecov/codecov-action@v4
4259
with:
4360
directory: ./coverage/
4461
fail_ci_if_error: true
45-
path_to_write_report: ./coverage/codecov_report.txt
4662
token: ${{ secrets.CODECOV_TOKEN }}

examples/node/call-acknowledge-action.js

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,49 @@
1717
/**
1818
* Logs in, loads list of user notes, then calls acknowledge action for the one
1919
*/
20-
'use strict';
21-
var Workfront = require('./../../');
22-
var ApiConstants = require('workfront-api-constants');
23-
var util = require('util');
20+
'use strict'
21+
var Workfront = require('./../../')
22+
var ApiConstants = require('@workfront/api-constants')
23+
var util = require('util')
2424

2525
var instance = new Workfront.NodeApi({
26-
url: 'http://localhost:8080',
27-
version: 'internal'
28-
});
26+
url: 'http://localhost:8080',
27+
version: 'internal',
28+
})
2929

30-
console.log('Logs in, loads list of user notes, then calls acknowledge action for the one\n');
31-
util.log('Logging in ...');
30+
console.log('Logs in, loads list of user notes, then calls acknowledge action for the one\n')
31+
util.log('Logging in ...')
3232
instance.login('[email protected]', 'user').then(
33-
function(data) {
34-
util.log('Loading list of user notes ...');
35-
var query = {};
36-
query[ApiConstants.LIMIT] = 1;
37-
instance.search('USRNOT', query).then(
38-
function(data) {
39-
util.log('Load success. Received data:');
40-
console.log(util.inspect(data, {colors:true}));
41-
util.log('Calling action for user note with objID=' + data[0].ID + ' ...');
42-
instance.execute('ack', null, 'acknowledge', {objID: data[0].ID, objCode:'USRNOT'}).then(
43-
function(data) {
44-
util.log('Action success. Received data:');
45-
console.log(util.inspect(data, {colors:true}));
46-
},
47-
function(error) {
48-
util.log('Action failure. Received data:');
49-
console.log(util.inspect(error, {colors:true}));
50-
}
51-
);
52-
},
53-
function(error) {
54-
util.log('Load failure. Received data:');
55-
console.log(util.inspect(error, {colors:true}));
56-
}
57-
);
58-
},
59-
function(error) {
60-
util.log('Login failure. Received data:');
61-
console.log(util.inspect(error, {colors:true}));
62-
}
63-
);
33+
function (data) {
34+
util.log('Loading list of user notes ...')
35+
var query = {}
36+
query[ApiConstants.LIMIT] = 1
37+
instance.search('USRNOT', query).then(
38+
function (data) {
39+
util.log('Load success. Received data:')
40+
console.log(util.inspect(data, {colors: true}))
41+
util.log('Calling action for user note with objID=' + data[0].ID + ' ...')
42+
instance
43+
.execute('ack', null, 'acknowledge', {objID: data[0].ID, objCode: 'USRNOT'})
44+
.then(
45+
function (data) {
46+
util.log('Action success. Received data:')
47+
console.log(util.inspect(data, {colors: true}))
48+
},
49+
function (error) {
50+
util.log('Action failure. Received data:')
51+
console.log(util.inspect(error, {colors: true}))
52+
},
53+
)
54+
},
55+
function (error) {
56+
util.log('Load failure. Received data:')
57+
console.log(util.inspect(error, {colors: true}))
58+
},
59+
)
60+
},
61+
function (error) {
62+
util.log('Login failure. Received data:')
63+
console.log(util.inspect(error, {colors: true}))
64+
},
65+
)

examples/node/call-assignUserToken-action-for-given-user.js

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,48 +18,50 @@
1818
* Logs in, loads list of active users, then calls assignUserToken action for the first user
1919
*/
2020

21-
'use strict';
22-
var Workfront = require('./../../');
23-
var ApiConstants = require('workfront-api-constants');
24-
var util = require('util');
21+
'use strict'
22+
var Workfront = require('./../../')
23+
var ApiConstants = require('@workfront/api-constants')
24+
var util = require('util')
2525

2626
var instance = new Workfront.NodeApi({
2727
url: 'http://localhost:8080',
28-
version: '7.0'
29-
});
28+
version: '7.0',
29+
})
3030

31-
console.log('Logs in, loads list of active users, then calls assignUserToken action for the first user\n');
32-
util.log('Logging in ...');
31+
console.log(
32+
'Logs in, loads list of active users, then calls assignUserToken action for the first user\n',
33+
)
34+
util.log('Logging in ...')
3335
instance.login('[email protected]', 'user').then(
34-
function(data) {
35-
util.log('Loading list of active users ...');
36-
var query = {};
37-
query['isActive'] = true;
38-
query[ApiConstants.LIMIT] = 1;
39-
instance.search('user', query).then(
40-
function(data) {
41-
util.log('Load success. Received data:');
42-
console.log(util.inspect(data, {colors:true}));
43-
util.log('Calling action for user with objID=' + data[0].ID + ' ...');
44-
instance.execute('user', data[0].ID, 'assignUserToken').then(
45-
function(data) {
46-
util.log('Action success. Received data:');
47-
console.log(util.inspect(data, {colors:true}));
48-
},
49-
function(error) {
50-
util.log('Action failure. Received data:');
51-
console.log(util.inspect(error, {colors:true}));
52-
}
53-
);
54-
},
55-
function(error) {
56-
util.log('Load failure. Received data:');
57-
console.log(util.inspect(error, {colors:true}));
58-
}
59-
);
60-
},
61-
function(error) {
62-
util.log('Login failure. Received data:');
63-
console.log(util.inspect(error, {colors:true}));
64-
}
65-
);
36+
function (data) {
37+
util.log('Loading list of active users ...')
38+
var query = {}
39+
query['isActive'] = true
40+
query[ApiConstants.LIMIT] = 1
41+
instance.search('user', query).then(
42+
function (data) {
43+
util.log('Load success. Received data:')
44+
console.log(util.inspect(data, {colors: true}))
45+
util.log('Calling action for user with objID=' + data[0].ID + ' ...')
46+
instance.execute('user', data[0].ID, 'assignUserToken').then(
47+
function (data) {
48+
util.log('Action success. Received data:')
49+
console.log(util.inspect(data, {colors: true}))
50+
},
51+
function (error) {
52+
util.log('Action failure. Received data:')
53+
console.log(util.inspect(error, {colors: true}))
54+
},
55+
)
56+
},
57+
function (error) {
58+
util.log('Load failure. Received data:')
59+
console.log(util.inspect(error, {colors: true}))
60+
},
61+
)
62+
},
63+
function (error) {
64+
util.log('Login failure. Received data:')
65+
console.log(util.inspect(error, {colors: true}))
66+
},
67+
)

0 commit comments

Comments
 (0)