npq 3.10.1 → 3.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/package.json +7 -1
  2. package/.editorconfig +0 -49
  3. package/.github/ISSUE_TEMPLATE.md +0 -32
  4. package/.github/Logo Horizontal.png +0 -0
  5. package/.github/Logo Vertical.png +0 -0
  6. package/.github/Logo.png +0 -0
  7. package/.github/PULL_REQUEST_TEMPLATE.md +0 -35
  8. package/.github/npq-demo-1.gif +0 -0
  9. package/.github/npq-demo-1.png +0 -0
  10. package/.github/npq-demo.gif +0 -0
  11. package/.github/npq.mov +0 -0
  12. package/.github/npq.mp4 +0 -0
  13. package/.github/npq.png +0 -0
  14. package/.github/workflows/automerge.yml +0 -39
  15. package/.github/workflows/main.yml +0 -58
  16. package/.husky/commit-msg +0 -4
  17. package/.husky/post-merge +0 -4
  18. package/.husky/pre-commit +0 -4
  19. package/.husky/pre-push +0 -4
  20. package/.prettierrc.js +0 -9
  21. package/CHANGELOG.md +0 -27
  22. package/CODE_OF_CONDUCT.md +0 -73
  23. package/CONTRIBUTING.md +0 -55
  24. package/SECURITY.md +0 -23
  25. package/__tests__/__fixtures__/test.marshall.js +0 -58
  26. package/__tests__/cli.parser.test.js +0 -121
  27. package/__tests__/cli.test.js +0 -110
  28. package/__tests__/cliPrompt.test.js +0 -409
  29. package/__tests__/env-var-integration.test.js +0 -109
  30. package/__tests__/marshalls.base.test.js +0 -113
  31. package/__tests__/marshalls.classMethods.test.js +0 -34
  32. package/__tests__/marshalls.expiredDomains.test.js +0 -100
  33. package/__tests__/marshalls.newBin.test.js +0 -441
  34. package/__tests__/marshalls.provenance.test.js +0 -383
  35. package/__tests__/marshalls.repo.test.js +0 -126
  36. package/__tests__/marshalls.signatures.test.js +0 -132
  37. package/__tests__/marshalls.snyk.test.js +0 -294
  38. package/__tests__/marshalls.tasks.test.js +0 -130
  39. package/__tests__/marshalls.typosquatting.test.js +0 -76
  40. package/__tests__/marshalls.version-maturity.test.js +0 -194
  41. package/__tests__/mocks/registryPackageOk.mock.json +0 -146
  42. package/__tests__/mocks/registryPackageUnpublished.mock.json +0 -31
  43. package/__tests__/packageManager.test.js +0 -93
  44. package/__tests__/packageRepoUtils.test.js +0 -251
  45. package/__tests__/reportResults.test.js +0 -772
  46. package/__tests__/scripts.test.js +0 -146
@@ -1,146 +0,0 @@
1
- {
2
- "_id": "dockly",
3
- "_rev": "19-8954e52e62d09cfaf1f4839d02fe0929",
4
- "name": "dockly",
5
- "description": "Interactive shell for managing Docker containers",
6
- "dist-tags": {
7
- "latest": "3.1.0"
8
- },
9
- "versions": {
10
- "3.1.0": {
11
- "name": "dockly",
12
- "version": "3.1.0",
13
- "description": "Interactive shell for managing Docker containers",
14
- "main": "index.js",
15
- "scripts": {
16
- "test": "yarn run lint",
17
- "lint": "standard",
18
- "lint:fix": "standard --fix"
19
- },
20
- "engines": {
21
- "node": ">=6.10.0"
22
- },
23
- "bin": {
24
- "dockly": "./index.js"
25
- },
26
- "repository": {
27
- "type": "git",
28
- "url": "git+https://github.com/lirantal/dockly.git"
29
- },
30
- "keywords": [
31
- "docker",
32
- "container",
33
- "cli",
34
- "shell",
35
- "blessed",
36
- "command",
37
- "command line",
38
- "console",
39
- "terminal"
40
- ],
41
- "author": {
42
- "name": "Liran Tal",
43
- "email": "liran.tal@gmail.com"
44
- },
45
- "license": "MIT",
46
- "bugs": {
47
- "url": "https://github.com/lirantal/dockly/issues"
48
- },
49
- "homepage": "https://github.com/lirantal/dockly#readme",
50
- "dependencies": {
51
- "blessed": "^0.1.81",
52
- "blessed-contrib": "^4.7.5",
53
- "chalk": "^2.0.1",
54
- "command-line-args": "^4.0.6",
55
- "command-line-usage": "^4.0.0",
56
- "dockerode": "^2.5.0",
57
- "figures": "^2.0.0",
58
- "glob": "^7.1.2",
59
- "opn": "^5.1.0"
60
- },
61
- "devDependencies": {
62
- "standard": "^10.0.2"
63
- },
64
- "gitHead": "28871c132d0b6a1fe574352af0d32b11fca2de88",
65
- "_id": "dockly@3.1.0",
66
- "_npmVersion": "5.5.1",
67
- "_nodeVersion": "8.4.0",
68
- "_npmUser": {
69
- "name": "lirantal",
70
- "email": "liran.tal@gmail.com"
71
- },
72
- "dist": {
73
- "integrity": "sha512-EJpDtbwaWF2yKhv6ee1jGo3Z+uCF/ESnVGR7LII3hvV6xWSreeJbOKlRRAHCtuA2U2HXwpk5qn1m/J9UqV0rrw==",
74
- "shasum": "22cb6bfd2f3bca9e18d5d24cef2c2d83c5780597",
75
- "tarball": "https://registry.npmjs.org/dockly/-/dockly-3.1.0.tgz"
76
- },
77
- "maintainers": [
78
- {
79
- "name": "lirantal",
80
- "email": "liran.tal@gmail.com"
81
- }
82
- ],
83
- "_npmOperationalInternal": {
84
- "host": "s3://npm-registry-packages",
85
- "tmp": "tmp/dockly-3.1.0.tgz_1509728182483_0.042640595231205225"
86
- },
87
- "directories": {}
88
- }
89
- },
90
- "readme": "<img width=\"200\" src=\"https://user-images.githubusercontent.com/316371/28937414-67ee5ffa-7893-11e7-95f9-5059cacf9170.png\">\n\n[![view on npm](http://img.shields.io/npm/v/dockly.svg)](https://www.npmjs.org/package/dockly)\n[![view on npm](http://img.shields.io/npm/l/dockly.svg)](https://www.npmjs.org/package/dockly)\n[![npm module downloads](http://img.shields.io/npm/dt/dockly.svg)](https://www.npmjs.org/package/dockly)\n[![Dependency Status](https://david-dm.org/lirantal/dockly.svg)](https://david-dm.org/lirantal/dockly)\n[![Codefresh build status]( https://g.codefresh.io/api/badges/build?repoOwner=lirantal&repoName=dockly&branch=master&pipelineName=dockly&accountName=lirantal&type=cf-1)]( https://g.codefresh.io/repositories/lirantal/dockly/builds?filter=trigger:build;branch:master;service:58127ed36b0e230100f421f6~dockly)\n\n# Dockly\nDocker console UI and Dashboard for quick manging and inspecting of Containers and Images\n\n![dockly-demo-2](https://cloud.githubusercontent.com/assets/316371/25682867/c5212216-3027-11e7-8f36-72d38516d2af.gif)\n\n# Install\nInstall the API module as a depdency in your project so you can easily use it to query Operations Orchestration REST API\n\n```javascript\nnpm install -g dockly\n```\n\n# Usage\n\nJust fire up dockly and it will automatically connect to your localhost docker daemon through the unix socket:\n\n```\ndockly\n```\n\n## Command line options:\n\nIt's also possible to provide command line options for dockly to customize the docker connection\n\n| Param | Type | Description |\n| --- | --- | --- |\n| -h or --host | string | Docker host to connect to |\n| -p or --port | string | Docker port to connect to |\n| -s or --socketPath | string | Docker socket to connect to |\n\n# Docker Support\n\n## Build\nYou can build dockly as a docker image yourself, using the following command:\n\n```\ndocker build -t dockly .\n```\n\n## Run\nTo run dockly as a container, invoke the following command:\n\n```\ndocker run -it --name dockly -v /var/run/docker.sock:/var/run/docker.sock dockly\n```\n\n# Author\nLiran Tal <liran.tal@gmail.com>\n",
91
- "maintainers": [
92
- {
93
- "name": "lirantal",
94
- "email": "liran.tal@gmail.com"
95
- }
96
- ],
97
- "time": {
98
- "modified": "2017-11-03T16:56:23.414Z",
99
- "created": "2016-10-25T08:58:11.022Z",
100
- "1.0.0": "2016-10-25T08:58:11.022Z",
101
- "1.1.0": "2016-11-02T17:21:35.452Z",
102
- "1.1.1": "2016-12-01T20:42:25.535Z",
103
- "1.1.2": "2016-12-01T22:48:29.751Z",
104
- "1.1.3": "2016-12-02T08:39:10.292Z",
105
- "1.1.4": "2017-03-10T08:53:16.270Z",
106
- "2.0.0": "2017-04-30T23:55:27.058Z",
107
- "2.0.1": "2017-05-01T16:47:38.941Z",
108
- "2.0.2": "2017-05-03T17:42:21.861Z",
109
- "2.1.0": "2017-05-27T17:10:14.551Z",
110
- "2.1.1": "2017-06-17T18:05:51.640Z",
111
- "2.1.2": "2017-08-02T19:15:47.545Z",
112
- "2.1.3": "2017-08-22T21:04:58.073Z",
113
- "2.1.4": "2017-08-30T22:05:58.507Z",
114
- "2.2.0": "2017-09-16T20:07:07.687Z",
115
- "2.3.0": "2017-09-19T21:18:10.460Z",
116
- "2.3.1": "2017-11-01T22:28:19.319Z",
117
- "3.0.0": "2017-11-03T16:48:38.068Z",
118
- "3.1.0": "2017-11-03T16:56:23.414Z"
119
- },
120
- "homepage": "https://github.com/lirantal/dockly#readme",
121
- "keywords": [
122
- "docker",
123
- "container",
124
- "cli",
125
- "shell",
126
- "blessed",
127
- "command",
128
- "command line",
129
- "console",
130
- "terminal"
131
- ],
132
- "repository": {
133
- "type": "git",
134
- "url": "git+https://github.com/lirantal/dockly.git"
135
- },
136
- "author": {
137
- "name": "Liran Tal",
138
- "email": "liran.tal@gmail.com"
139
- },
140
- "bugs": {
141
- "url": "https://github.com/lirantal/dockly/issues"
142
- },
143
- "license": "MIT",
144
- "readmeFilename": "README.md",
145
- "_attachments": {}
146
- }
@@ -1,31 +0,0 @@
1
- {
2
- "_id": "getcookies",
3
- "_rev": "4-2f7fba6f65b5c54ec24fa63f6e0325e7",
4
- "name": "getcookies",
5
- "time": {
6
- "created": "2018-03-22T07:45:55.796Z",
7
- "1.12.1": "2018-03-22T07:45:55.879Z",
8
- "modified": "2018-05-02T14:11:16.630Z",
9
- "1.12.2": "2018-03-22T07:47:25.395Z",
10
- "1.12.3": "2018-03-22T07:51:03.630Z",
11
- "unpublished": {
12
- "name": "npm",
13
- "time": "2018-05-02T14:11:16.630Z",
14
- "tags": {
15
- "latest": "1.12.3"
16
- },
17
- "maintainers": [
18
- {
19
- "name": "dustin87",
20
- "email": "dustin.heidenreich@hotmail.com"
21
- }
22
- ],
23
- "versions": [
24
- "1.12.1",
25
- "1.12.2",
26
- "1.12.3"
27
- ]
28
- }
29
- },
30
- "_attachments": {}
31
- }
@@ -1,93 +0,0 @@
1
- const packageManager = require('../lib/packageManager')
2
-
3
- const childProcess = require('child_process')
4
-
5
- jest.mock('child_process', () => {
6
- return {
7
- // eslint-disable-next-line no-unused-vars
8
- spawn: jest.fn((cmd, args, options) => {
9
- return true
10
- })
11
- }
12
- })
13
-
14
- test('package manager validation should fail if provided array', () => {
15
- expect(() => packageManager.validatePackageManager(['something'])).toThrow()
16
- })
17
-
18
- test('package manager validation should fail if provided function', () => {
19
- expect(() => packageManager.validatePackageManager(() => {})).toThrow()
20
- })
21
- test('package manager validation should fail if provided boolean', () => {
22
- expect(() => packageManager.validatePackageManager(true)).toThrow()
23
- })
24
-
25
- test('package manager validation should fail if provided object', () => {
26
- expect(() => packageManager.validatePackageManager({ a: 'b' })).toThrow()
27
- })
28
-
29
- test('package manager has a default manager configured', () => {
30
- expect(packageManager.getDefaultPackageManager()).toBeTruthy()
31
- })
32
-
33
- test('package manager spawns successfully when provided valid package manager', async () => {
34
- await packageManager.process('npm')
35
- expect(childProcess.spawn).toHaveBeenCalled()
36
- expect(childProcess.spawn.mock.calls.length).toBe(1)
37
- expect(childProcess.spawn.mock.calls[0][0]).toBe('npm')
38
-
39
- childProcess.spawn.mockReset()
40
- })
41
-
42
- test('package manager spawns successfully when retrieves default package manager', async () => {
43
- await packageManager.process()
44
- expect(childProcess.spawn).toHaveBeenCalled()
45
- expect(childProcess.spawn.mock.calls.length).toBe(1)
46
- expect(childProcess.spawn.mock.calls[0][0]).toBe('npm')
47
-
48
- childProcess.spawn.mockReset()
49
- })
50
-
51
- test('package manager spawns successfully when provided array of packages to handle', async () => {
52
- process.argv = ['node', 'script name', 'install', 'semver', 'express']
53
- await packageManager.process('npm')
54
- expect(childProcess.spawn).toHaveBeenCalled()
55
- expect(childProcess.spawn.mock.calls.length).toBe(1)
56
- expect(childProcess.spawn.mock.calls[0][0]).toEqual('npm install semver express')
57
- childProcess.spawn.mockReset()
58
- })
59
-
60
- test("package manager spawns successfully and ignore npq's own internal commands when spawning package manager", async () => {
61
- process.argv = [
62
- 'node',
63
- 'script name',
64
- 'install',
65
- 'semver',
66
- 'express',
67
- '--dry-run',
68
- '--packageManager'
69
- ]
70
- await packageManager.process('npm')
71
- expect(childProcess.spawn).toHaveBeenCalled()
72
- expect(childProcess.spawn.mock.calls.length).toBe(1)
73
- expect(childProcess.spawn.mock.calls[0][0]).toEqual('npm install semver express')
74
- childProcess.spawn.mockReset()
75
- })
76
-
77
- test('package manager spawns with yarn when provided as parameter', async () => {
78
- process.argv = ['node', 'script name', 'install', 'express']
79
- await packageManager.process('yarn')
80
- expect(childProcess.spawn).toHaveBeenCalled()
81
- expect(childProcess.spawn.mock.calls.length).toBe(1)
82
- expect(childProcess.spawn.mock.calls[0][0]).toEqual('yarn install express')
83
- childProcess.spawn.mockReset()
84
- })
85
-
86
- test('package manager spawns with pnpm when provided as parameter', async () => {
87
- process.argv = ['node', 'script name', 'install', 'lodash']
88
- await packageManager.process('pnpm')
89
- expect(childProcess.spawn).toHaveBeenCalled()
90
- expect(childProcess.spawn.mock.calls.length).toBe(1)
91
- expect(childProcess.spawn.mock.calls[0][0]).toEqual('pnpm install lodash')
92
- childProcess.spawn.mockReset()
93
- })
@@ -1,251 +0,0 @@
1
- const PackageRepoUtils = require('../lib/helpers/packageRepoUtils')
2
-
3
- global.fetch = jest.fn().mockImplementation(() =>
4
- Promise.resolve({
5
- json: () => require('./mocks/registryPackageOk.mock.json')
6
- })
7
- )
8
-
9
- beforeEach(() => {
10
- fetch.mockClear()
11
- })
12
-
13
- test('repo utils always has a default package registry url', () => {
14
- const packageRepoUtils = new PackageRepoUtils()
15
- expect(packageRepoUtils.registryUrl).toBeTruthy()
16
- })
17
-
18
- test('repo utils constructor allows setting a package registry url', () => {
19
- const pkgRegistryUrl = 'https://registry.yarnpkg.com'
20
- const packageRepoUtils = new PackageRepoUtils({
21
- registryUrl: pkgRegistryUrl
22
- })
23
- expect(packageRepoUtils.registryUrl).toEqual(pkgRegistryUrl)
24
- })
25
-
26
- test('repo utils constructor allows setting a package registry api url', () => {
27
- const pkgRegistryApiUrl = 'https://api.npmjs.org'
28
- const packageRepoUtils = new PackageRepoUtils({
29
- registryApiUrl: pkgRegistryApiUrl
30
- })
31
- expect(packageRepoUtils.registryApiUrl).toEqual(pkgRegistryApiUrl)
32
- })
33
-
34
- test('repo utils returns a package json object from registry', async () => {
35
- const packageRepoUtils = new PackageRepoUtils()
36
- const packageName = 'testPackage'
37
- const result = await packageRepoUtils.getPackageInfo(packageName)
38
- expect(result).toBeTruthy()
39
- })
40
-
41
- test('repo utils uses its cache when called with wit the same parameter for the second time', async () => {
42
- const packageRepoUtils = new PackageRepoUtils()
43
- const packageName = 'testPackage'
44
- await packageRepoUtils.getPackageInfo(packageName)
45
- await packageRepoUtils.getPackageInfo(packageName)
46
- expect(fetch.mock.calls.length).toEqual(1)
47
- })
48
-
49
- test('repo utils retrieves package latest version', async () => {
50
- const packageRepoUtils = new PackageRepoUtils()
51
- const packageName = 'testPackage'
52
- const result = await packageRepoUtils.getLatestVersion(packageName)
53
- expect(result).toEqual('3.1.0')
54
- })
55
-
56
- test('repo utils retrieves package README information', async () => {
57
- const packageRepoUtils = new PackageRepoUtils()
58
- const packageName = 'testPackage'
59
- const result = await packageRepoUtils.getReadmeInfo(packageName)
60
- expect(result).toContain('dockly')
61
- })
62
-
63
- test('repo utils retrieves package latest version as null if not exists', async () => {
64
- const PackageRepoUtils = require('../lib/helpers/packageRepoUtils')
65
- global.fetch = jest.fn().mockImplementation(() =>
66
- Promise.resolve({
67
- json: () => require('./mocks/registryPackageUnpublished.mock.json')
68
- })
69
- )
70
-
71
- const packageRepoUtils = new PackageRepoUtils()
72
- const packageName = 'testPackage'
73
- const result = await packageRepoUtils.getLatestVersion(packageName)
74
- expect(result).toEqual(null)
75
- })
76
-
77
- test('repo utils retrieves package download count', async () => {
78
- const PackageRepoUtils = require('../lib/helpers/packageRepoUtils')
79
- global.fetch = jest.fn().mockImplementation(() =>
80
- Promise.resolve({
81
- json: () => ({
82
- downloads: 1950,
83
- start: '2017-11-26',
84
- end: '2017-12-25',
85
- package: 'express-version-route'
86
- })
87
- })
88
- )
89
-
90
- const packageRepoUtils = new PackageRepoUtils()
91
- const packageName = 'testPackage'
92
- const result = await packageRepoUtils.getDownloadInfo(packageName)
93
- expect(result).toEqual(1950)
94
- })
95
-
96
- test('repo utils retrieves package README information even when not available', async () => {
97
- const PackageRepoUtils = require('../lib/helpers/packageRepoUtils')
98
- global.fetch = jest.fn().mockImplementation(() =>
99
- Promise.resolve({
100
- json: () => require('./mocks/registryPackageUnpublished.mock.json')
101
- })
102
- )
103
-
104
- const packageRepoUtils = new PackageRepoUtils()
105
- const packageName = 'testPackage'
106
- const result = await packageRepoUtils.getReadmeInfo(packageName)
107
- expect(result).toBeFalsy()
108
- })
109
-
110
- test('repo utils retrieves package LICENSE information', async () => {
111
- const PackageRepoUtils = require('../lib/helpers/packageRepoUtils')
112
- global.fetch = jest.fn().mockImplementation(() =>
113
- Promise.resolve({
114
- json: () => require('./mocks/registryPackageOk.mock.json')
115
- })
116
- )
117
-
118
- const packageRepoUtils = new PackageRepoUtils()
119
- const packageName = 'testPackage'
120
- const result = await packageRepoUtils.getLicenseInfo(packageName)
121
- expect(result).toBeTruthy()
122
- })
123
-
124
- test('repo utils parses package version', async () => {
125
- const PackageRepoUtils = require('../lib/helpers/packageRepoUtils')
126
- global.fetch = jest.fn().mockImplementation(() =>
127
- Promise.resolve({
128
- json: () => require('./mocks/registryPackageOk.mock.json')
129
- })
130
- )
131
-
132
- const packageRepoUtils = new PackageRepoUtils()
133
- const packageName = 'testPackage'
134
- const result = await packageRepoUtils.parsePackageVersion(
135
- await packageRepoUtils.getLatestVersion(packageName)
136
- )
137
- expect(result).toBeTruthy()
138
- })
139
-
140
- test('repo utils returns valid semver for different cases of version asked', async () => {
141
- const PackageRepoUtils = require('../lib/helpers/packageRepoUtils')
142
- global.fetch = jest.fn().mockImplementation(() =>
143
- Promise.resolve({
144
- json: () => require('./mocks/registryPackageOk.mock.json')
145
- })
146
- )
147
-
148
- const packageRepoUtils = new PackageRepoUtils()
149
- const packageName = 'testPackage'
150
-
151
- let result
152
-
153
- result = await packageRepoUtils.getSemVer(packageName, 'latest')
154
- expect(result).toEqual('3.1.0')
155
-
156
- result = await packageRepoUtils.getSemVer(packageName, '3.1.0')
157
- expect(result).toEqual('3.1.0')
158
-
159
- await expect(packageRepoUtils.getSemVer(packageName, 'next')).rejects.toThrow(
160
- 'Could not find dist-tag next for package testPackage'
161
- )
162
- })
163
-
164
- test('repo utils resolves semver ranges by finding the highest satisfying version', async () => {
165
- const PackageRepoUtils = require('../lib/helpers/packageRepoUtils')
166
- global.fetch = jest.fn().mockImplementation(() =>
167
- Promise.resolve({
168
- json: () => require('./mocks/registryPackageOk.mock.json')
169
- })
170
- )
171
-
172
- const packageRepoUtils = new PackageRepoUtils()
173
- const packageName = 'testPackage'
174
-
175
- // Test major version range - should find highest 3.x version (3.1.0)
176
- let result = await packageRepoUtils.getSemVer(packageName, '^3.0.0')
177
- expect(result).toEqual('3.1.0')
178
-
179
- // Test simple major version - should find highest 3.x version (3.1.0)
180
- result = await packageRepoUtils.getSemVer(packageName, '3')
181
- expect(result).toEqual('3.1.0')
182
-
183
- // Test tilde range - should find 3.1.x version (3.1.0)
184
- result = await packageRepoUtils.getSemVer(packageName, '~3.1.0')
185
- expect(result).toEqual('3.1.0')
186
-
187
- // Test invalid semver range that doesn't match any version
188
- await expect(packageRepoUtils.getSemVer(packageName, '^10.0.0')).rejects.toThrow(
189
- 'Could not find dist-tag ^10.0.0 for package testPackage'
190
- )
191
-
192
- // Test invalid semver range with version 2 (no 2.x versions in mock)
193
- await expect(packageRepoUtils.getSemVer(packageName, '2')).rejects.toThrow(
194
- 'Could not find dist-tag 2 for package testPackage'
195
- )
196
- })
197
-
198
- test('repo utils resolves semver ranges with multiple versions', async () => {
199
- const PackageRepoUtils = require('../lib/helpers/packageRepoUtils')
200
-
201
- // Create a more comprehensive mock that includes multiple versions
202
- const comprehensiveMock = {
203
- name: '@astrojs/vue',
204
- 'dist-tags': {
205
- latest: '4.5.0'
206
- },
207
- versions: {
208
- '1.2.0': { name: '@astrojs/vue', version: '1.2.0' },
209
- '2.0.0': { name: '@astrojs/vue', version: '2.0.0' },
210
- '2.1.0': { name: '@astrojs/vue', version: '2.1.0' },
211
- '2.2.1': { name: '@astrojs/vue', version: '2.2.1' },
212
- '3.0.0': { name: '@astrojs/vue', version: '3.0.0' },
213
- '3.1.0': { name: '@astrojs/vue', version: '3.1.0' },
214
- '3.2.2': { name: '@astrojs/vue', version: '3.2.2' },
215
- '4.0.0': { name: '@astrojs/vue', version: '4.0.0' },
216
- '4.5.0': { name: '@astrojs/vue', version: '4.5.0' }
217
- }
218
- }
219
-
220
- global.fetch = jest.fn().mockImplementation(() =>
221
- Promise.resolve({
222
- json: () => comprehensiveMock
223
- })
224
- )
225
-
226
- const packageRepoUtils = new PackageRepoUtils()
227
- const packageName = '@astrojs/vue'
228
-
229
- // Test the problematic case mentioned in the issue: "@astrojs/vue@3"
230
- let result = await packageRepoUtils.getSemVer(packageName, '3')
231
- expect(result).toEqual('3.2.2') // Should find highest 3.x version
232
-
233
- // Test other major versions
234
- result = await packageRepoUtils.getSemVer(packageName, '2')
235
- expect(result).toEqual('2.2.1') // Should find highest 2.x version
236
-
237
- result = await packageRepoUtils.getSemVer(packageName, '4')
238
- expect(result).toEqual('4.5.0') // Should find highest 4.x version
239
-
240
- // Test caret ranges
241
- result = await packageRepoUtils.getSemVer(packageName, '^3.0.0')
242
- expect(result).toEqual('3.2.2')
243
-
244
- result = await packageRepoUtils.getSemVer(packageName, '^2.1.0')
245
- expect(result).toEqual('2.2.1')
246
-
247
- // Test that non-existent major versions still fail appropriately
248
- await expect(packageRepoUtils.getSemVer(packageName, '10')).rejects.toThrow(
249
- 'Could not find dist-tag 10 for package @astrojs/vue'
250
- )
251
- })