Skip to content

Commit 82acfdb

Browse files
chore: dev dependencies cleanup + new node version support in CI
* chore: upgraded nyc and jsdoc * chore: include node 20+22 in CI * chore: ignore vscode files * chore: using [email protected] * fix: fixed specs * fix: fixed specs * fix: fixed specs
1 parent d12a63f commit 82acfdb

File tree

5 files changed

+22
-56
lines changed

5 files changed

+22
-56
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ coverage
1414
tools/cloudinary_url.sh
1515
package-lock.json
1616
npm-debug.log
17+
.vscode/

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
language: node_js
2-
nvm:
32
dist: focal
43
matrix:
54
include:
@@ -15,6 +14,11 @@ matrix:
1514
script: npm run test-with-temp-cloud
1615
- node_js: "18"
1716
script: npm run test-with-temp-cloud
17+
- node_js: "20"
18+
script: npm run test-with-temp-cloud
19+
- node_js: "22"
20+
script: npm run test-with-temp-cloud
21+
1822

1923
notifications:
2024
email:

lib/utils/analytics/getSDKVersions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ function getSDKVersions(useSDKVersion = 'default', useNodeVersion = 'default') {
2626
const sdkSemver = useSDKVersion === 'default' ? readSdkSemver() : useSDKVersion;
2727

2828
// allow to pass a custom techVersion (Node version)
29-
const techVersion = useNodeVersion === 'default' ? process.versions.node : useNodeVersion;
29+
const version = process.version.slice(1);
30+
const techVersion = useNodeVersion === 'default' ? version : useNodeVersion;
3031

3132
const product = 'A';
3233

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"q": "^1.5.1"
1616
},
1717
"devDependencies": {
18+
"@types/expect.js": "^0.3.29",
1819
"@types/mocha": "^7.0.2",
1920
"@types/node": "^13.5.0",
20-
"@types/expect.js": "^0.3.29",
2121
"date-fns": "^2.16.1",
2222
"dotenv": "4.x",
2323
"dtslint": "^0.9.1",
@@ -26,12 +26,11 @@
2626
"eslint-plugin-import": "^2.20.2",
2727
"expect.js": "0.3.x",
2828
"glob": "^7.1.6",
29-
"jsdoc": "3.5.5",
29+
"jsdoc": "^3.6.11",
3030
"jsdom": "^9.12.0",
3131
"jsdom-global": "2.1.1",
3232
"mocha": "^6.2.3",
33-
"mock-fs": "^4.12.0",
34-
"nyc": "^13.3.0",
33+
"nyc": "^14.1.1",
3534
"rimraf": "^3.0.0",
3635
"sinon": "^6.1.4",
3736
"typescript": "^3.7.5",

test/unit/sdkAnalytics/imageTagWithAnalytics.spec.js

Lines changed: 11 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const path = require('path');
2-
const mock = require('mock-fs');
32
const assert = require("assert");
43
const sinon = require("sinon");
54
const fs = require('fs');
@@ -11,35 +10,21 @@ const TEST_CLOUD_NAME = require('../../testUtils/testConstants').TEST_CLOUD_NAME
1110
describe('SDK url analytics', () => {
1211
let processVersions = {};
1312

14-
before(() => {
13+
beforeEach(() => {
1514
cloudinary.config(true); // reset
16-
17-
processVersions = process.versions;
18-
delete process.versions;
19-
});
20-
21-
after(() => {
22-
process.versions = processVersions;
15+
cloudinary.config({
16+
techVersion: '12.0.0'
17+
});
2318
});
2419

2520
describe('when package json is available', () => {
26-
before(() => {
27-
const file = path.join(__dirname, '../../../package.json');
28-
29-
mock({
30-
[file]: '{"version":"1.24.0"}'
21+
beforeEach(() => {
22+
cloudinary.config({
23+
sdkSemver: '1.24.0'
3124
});
3225
});
3326

34-
after(() => {
35-
mock.restore();
36-
});
37-
3827
it('can be turned off via options', () => {
39-
process.versions = {
40-
node: '12.0.0'
41-
};
42-
4328
const imgStr = cloudinary.image("hello", {
4429
format: "png",
4530
analytics: false
@@ -49,10 +34,6 @@ describe('SDK url analytics', () => {
4934
});
5035

5136
it('defaults to true even if analytics is not passed as an option', () => {
52-
process.versions = {
53-
node: '12.0.0'
54-
};
55-
5637
const imgStr = cloudinary.image("hello", {
5738
format: "png"
5839
});
@@ -61,10 +42,6 @@ describe('SDK url analytics', () => {
6142
});
6243

6344
it('reads from process.versions and package.json (Mocked)', () => {
64-
process.versions = {
65-
node: '12.0.0'
66-
};
67-
6845
const imgStr = cloudinary.image("hello", {
6946
format: "png",
7047
analytics: true
@@ -74,12 +51,8 @@ describe('SDK url analytics', () => {
7451
});
7552

7653
it('reads from process.versions and package.json (Mocked) - Responsive', () => {
77-
process.versions = {
78-
node: '12.0.0'
79-
};
80-
8154
const imgStr = cloudinary.image("hello", {
82-
format: "png",
55+
format: 'png',
8356
responsive: true,
8457
analytics: true
8558
});
@@ -88,9 +61,7 @@ describe('SDK url analytics', () => {
8861
});
8962

9063
it('reads from tracked analytics configuration', () => {
91-
process.versions = {
92-
node: '12.0.0'
93-
};
64+
cloudinary.config(true); // reset
9465

9566
const imgStr = cloudinary.image("hello", {
9667
format: "png",
@@ -105,10 +76,6 @@ describe('SDK url analytics', () => {
10576
});
10677

10778
it('should still accept analytics param passed as camel case', () => {
108-
process.versions = {
109-
node: '12.0.0'
110-
};
111-
11279
const imgStr = cloudinary.image("hello", {
11380
format: "png",
11481
urlAnalytics: true,
@@ -123,10 +90,6 @@ describe('SDK url analytics', () => {
12390

12491
describe('with two different casings', () => {
12592
it('should treat camel case analytics param as more important than snake case', () => {
126-
process.versions = {
127-
node: '12.0.0'
128-
};
129-
13093
const imgStr1 = cloudinary.image("hello", {
13194
format: "png",
13295
urlAnalytics: true,
@@ -157,17 +120,15 @@ describe('SDK url analytics', () => {
157120
const enoent = new Error('ENOENT');
158121
enoent.code = 'ENOENT';
159122
sinon.stub(fs, 'readFileSync').throws(enoent);
123+
124+
cloudinary.config(true); // reset
160125
});
161126

162127
after(() => {
163128
sinon.restore();
164129
});
165130

166131
it('uses 0.0.0 as fallback sdk semver', () => {
167-
process.versions = {
168-
node: '12.0.0'
169-
};
170-
171132
const urlWithToken = cloudinary.url("hello", {
172133
format: "png",
173134
analytics: true

0 commit comments

Comments
 (0)