Skip to content

Commit

Permalink
feat(2683): nodejs upgrade (#36)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Node 18 upgrade && eslint upgrade
  • Loading branch information
klu909 authored Dec 2, 2022
1 parent 79c7b20 commit c47ee9a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 27 deletions.
6 changes: 1 addition & 5 deletions bin/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ const nomnom = require('nomnom');
const { operations } = require('../commands');

Object.keys(operations).forEach(key => {
nomnom
.command(key)
.options(operations[key].opts)
.callback(operations[key].exec)
.help(operations[key].help);
nomnom.command(key).options(operations[key].opts).callback(operations[key].exec).help(operations[key].help);
});

nomnom.parse();
5 changes: 1 addition & 4 deletions commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,7 @@ const operations = {
* @return {Object} result of command, if any
*/
function run(name) {
const opts = nomnom
.options(operations[name].opts)
.help(operations[name].help)
.parse();
const opts = nomnom.options(operations[name].opts).help(operations[name].help).parse();

return operations[name].exec(opts);
}
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const Yaml = require('js-yaml');
* @return {Promise} Promise that resolves to the template as a config object
*/
function loadYaml(path) {
return new Promise(resolve => resolve(Yaml.safeLoad(fs.readFileSync(path, 'utf8'))));
return new Promise(resolve => {
resolve(Yaml.load(fs.readFileSync(path, 'utf8')));
});
}

/**
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "screwdriver-template-main",
"version": "1.0.0",
"version": "2.0.0",
"description": "Validates, publishes, and tags templates",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -41,25 +41,25 @@
"Tiffany Kyi <[email protected]>"
],
"devDependencies": {
"chai": "^4.3.4",
"eslint": "^7.31.0",
"eslint-config-screwdriver": "^5.0.1",
"mocha": "^8.2.1",
"chai": "^4.3.7",
"eslint": "^8.28.0",
"eslint-config-screwdriver": "^7.0.0",
"mocha": "^10.1.0",
"mocha-multi-reporters": "^1.5.1",
"mocha-sonarqube-reporter": "^1.0.2",
"mockery": "^2.0.0",
"nyc": "^15.0.0",
"sinon": "^9.0.0"
"mockery": "^2.1.0",
"nyc": "^15.1.0",
"sinon": "^15.0.0"
},
"dependencies": {
"js-yaml": "^3.14.1",
"js-yaml": "^4.1.0",
"nomnom": "^1.8.1",
"screwdriver-request": "^1.0.1"
"screwdriver-request": "^2.0.1"
},
"release": {
"debug": false
},
"engines": {
"node": ">=12.0.0"
"node": ">=18.0.0"
}
}
2 changes: 1 addition & 1 deletion screwdriver.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
shared:
image: node:12
image: node:18

jobs:
main:
Expand Down
11 changes: 6 additions & 5 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('index', () => {
beforeEach(() => {
requestMock = sinon.stub();
YamlMock = {
safeLoad: sinon.stub()
load: sinon.stub()
};
fsMock = {
readFileSync: sinon.stub()
Expand All @@ -39,7 +39,7 @@ describe('index', () => {
}
};

YamlMock.safeLoad.returns(templateConfig);
YamlMock.load.returns(templateConfig);

mockery.registerMock('fs', fsMock);
mockery.registerMock('js-yaml', YamlMock);
Expand All @@ -61,7 +61,7 @@ describe('index', () => {

describe('Load Yaml', () => {
it('resolves if loads successfully', () => {
YamlMock.safeLoad.resolves('yamlcontent');
YamlMock.load.resolves('yamlcontent');

return index.loadYaml(config => assert.equal(config, 'yamlcontent'));
});
Expand Down Expand Up @@ -263,8 +263,9 @@ describe('index', () => {
});
});
describe('Template Tag', () => {
const url = `${process.env.SD_API_URL ||
'https://api.screwdriver.cd/v4/'}templates/template%2Ftest/tags/stable`;
const url = `${
process.env.SD_API_URL || 'https://api.screwdriver.cd/v4/'
}templates/template%2Ftest/tags/stable`;

describe('Create/Update a tag', () => {
const config = {
Expand Down

0 comments on commit c47ee9a

Please sign in to comment.