npq 3.10.1 → 3.11.0
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.
- package/package.json +27 -20
- package/.editorconfig +0 -49
- package/.github/ISSUE_TEMPLATE.md +0 -32
- package/.github/Logo Horizontal.png +0 -0
- package/.github/Logo Vertical.png +0 -0
- package/.github/Logo.png +0 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -35
- package/.github/npq-demo-1.gif +0 -0
- package/.github/npq-demo-1.png +0 -0
- package/.github/npq-demo.gif +0 -0
- package/.github/npq.mov +0 -0
- package/.github/npq.mp4 +0 -0
- package/.github/npq.png +0 -0
- package/.github/workflows/automerge.yml +0 -39
- package/.github/workflows/main.yml +0 -58
- package/.husky/commit-msg +0 -4
- package/.husky/post-merge +0 -4
- package/.husky/pre-commit +0 -4
- package/.husky/pre-push +0 -4
- package/.prettierrc.js +0 -9
- package/CHANGELOG.md +0 -27
- package/CODE_OF_CONDUCT.md +0 -73
- package/CONTRIBUTING.md +0 -55
- package/SECURITY.md +0 -23
- package/__tests__/__fixtures__/test.marshall.js +0 -58
- package/__tests__/cli.parser.test.js +0 -121
- package/__tests__/cli.test.js +0 -110
- package/__tests__/cliPrompt.test.js +0 -409
- package/__tests__/env-var-integration.test.js +0 -109
- package/__tests__/marshalls.base.test.js +0 -113
- package/__tests__/marshalls.classMethods.test.js +0 -34
- package/__tests__/marshalls.expiredDomains.test.js +0 -100
- package/__tests__/marshalls.newBin.test.js +0 -441
- package/__tests__/marshalls.provenance.test.js +0 -383
- package/__tests__/marshalls.repo.test.js +0 -126
- package/__tests__/marshalls.signatures.test.js +0 -132
- package/__tests__/marshalls.snyk.test.js +0 -294
- package/__tests__/marshalls.tasks.test.js +0 -130
- package/__tests__/marshalls.typosquatting.test.js +0 -76
- package/__tests__/marshalls.version-maturity.test.js +0 -194
- package/__tests__/mocks/registryPackageOk.mock.json +0 -146
- package/__tests__/mocks/registryPackageUnpublished.mock.json +0 -31
- package/__tests__/packageManager.test.js +0 -93
- package/__tests__/packageRepoUtils.test.js +0 -251
- package/__tests__/reportResults.test.js +0 -772
- package/__tests__/scripts.test.js +0 -146
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const os = require('os')
|
|
3
|
-
const path = require('path')
|
|
4
|
-
const cliPrompt = require('../lib/helpers/cliPrompt.js')
|
|
5
|
-
|
|
6
|
-
const postinstall = require('../scripts/postinstall').testable
|
|
7
|
-
const preuninstall = require('../scripts/preuninstall').testable
|
|
8
|
-
const helpers = require('../scripts/scriptHelpers')
|
|
9
|
-
|
|
10
|
-
const TEST_PROFILE_PATH = path.resolve(os.tmpdir(), '.npq_test_profile')
|
|
11
|
-
const TEST_ALIAS = 'alias npm="npq-hero"'
|
|
12
|
-
cliPrompt.prompt = jest.fn().mockResolvedValue({ install: true })
|
|
13
|
-
|
|
14
|
-
let mockGetShellConfig
|
|
15
|
-
let mockIsRunningInYarn
|
|
16
|
-
let mockGetNpmVersion
|
|
17
|
-
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
mockGetShellConfig = jest.spyOn(helpers, 'getShellConfig').mockImplementation(() => ({
|
|
20
|
-
name: 'testShell',
|
|
21
|
-
profilePath: TEST_PROFILE_PATH,
|
|
22
|
-
aliases: TEST_ALIAS
|
|
23
|
-
}))
|
|
24
|
-
// Our install script does not run when installing with yarn, but we still want to be able to run tests with yarn
|
|
25
|
-
mockIsRunningInYarn = jest.spyOn(helpers, 'isRunningInYarn').mockImplementation(() => false)
|
|
26
|
-
// Our install script does not run when installing with npm V7, but we still want to be able to run tests with all npm versions
|
|
27
|
-
mockGetNpmVersion = jest.spyOn(helpers, 'getNpmVersion').mockImplementation(() => '6.0.0')
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
afterEach(async () => {
|
|
31
|
-
try {
|
|
32
|
-
// eslint-disable-next-line security/detect-non-literal-fs-filename
|
|
33
|
-
await fs.promises.unlink(TEST_PROFILE_PATH)
|
|
34
|
-
} catch (err) {
|
|
35
|
-
if (err.code === 'ENOENT') {
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
throw err
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
test('postinstall stops when detecting unknown shell', async () => {
|
|
43
|
-
mockGetShellConfig.mockRestore()
|
|
44
|
-
process.env.SHELL = '/usr/bin/fakeshell'
|
|
45
|
-
|
|
46
|
-
await postinstall.runPostInstall()
|
|
47
|
-
const containsAlias = await helpers.fileContains(TEST_PROFILE_PATH, TEST_ALIAS)
|
|
48
|
-
expect(containsAlias).toBe(false)
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
test('postinstall script does not run in yarn', async () => {
|
|
52
|
-
// yarn does not allow for stdin input during `yarn global add npq`
|
|
53
|
-
mockIsRunningInYarn.mockRestore()
|
|
54
|
-
const oldExecPath = process.env.npm_execpath
|
|
55
|
-
|
|
56
|
-
const spy = jest.spyOn(console, 'log')
|
|
57
|
-
// pretend that we're running in yarn, whether or not we actually are
|
|
58
|
-
process.env.npm_execpath = '/example/path/to/yarn.js'
|
|
59
|
-
|
|
60
|
-
await postinstall.runPostInstall()
|
|
61
|
-
expect(spy).not.toHaveBeenCalled()
|
|
62
|
-
|
|
63
|
-
process.env.npm_execpath = oldExecPath
|
|
64
|
-
spy.mockRestore()
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
test('postinstall script does not run in npm v7', async () => {
|
|
68
|
-
// npm v7 does not allow for stdin input during `npm install [-g] npq`
|
|
69
|
-
mockGetNpmVersion.mockRestore()
|
|
70
|
-
const oldUserAgent = process.env.npm_config_user_agent
|
|
71
|
-
|
|
72
|
-
const spy = jest.spyOn(console, 'log')
|
|
73
|
-
// pretend that we're running in npm v7, whether or not we actually are
|
|
74
|
-
process.env.npm_config_user_agent = 'npm/7.19.1 node/v14.16.1 win32 x64 workspaces/false'
|
|
75
|
-
|
|
76
|
-
await postinstall.runPostInstall()
|
|
77
|
-
expect(spy).not.toHaveBeenCalled()
|
|
78
|
-
|
|
79
|
-
process.env.npm_config_user_agent = oldUserAgent
|
|
80
|
-
spy.mockRestore()
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
test('postinstall script adds aliases', async () => {
|
|
84
|
-
await postinstall.runPostInstall()
|
|
85
|
-
|
|
86
|
-
const containsAlias = await helpers.fileContains(TEST_PROFILE_PATH, TEST_ALIAS)
|
|
87
|
-
expect(containsAlias).toBe(true)
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
test('postinstall script does not create duplicate aliases', async () => {
|
|
91
|
-
await postinstall.runPostInstall()
|
|
92
|
-
await postinstall.runPostInstall()
|
|
93
|
-
|
|
94
|
-
const containsAlias = await helpers.fileContains(TEST_PROFILE_PATH, TEST_ALIAS)
|
|
95
|
-
const containsDoubleAlias = await helpers.fileContains(
|
|
96
|
-
TEST_PROFILE_PATH,
|
|
97
|
-
`${TEST_ALIAS}${TEST_ALIAS}`
|
|
98
|
-
)
|
|
99
|
-
expect(containsAlias).toBe(true)
|
|
100
|
-
expect(containsDoubleAlias).toBe(false)
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
test('uninstall script removes aliases', async () => {
|
|
104
|
-
await postinstall.runPostInstall()
|
|
105
|
-
await preuninstall.runPreUninstall()
|
|
106
|
-
|
|
107
|
-
const containsAlias = await helpers.fileContains(TEST_PROFILE_PATH, TEST_ALIAS)
|
|
108
|
-
expect(containsAlias).toBe(false)
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
test('uninstall script does nothing in unknown shell', async () => {
|
|
112
|
-
await postinstall.runPostInstall()
|
|
113
|
-
|
|
114
|
-
mockGetShellConfig.mockRestore()
|
|
115
|
-
process.env.SHELL = '/usr/bin/fakeshell'
|
|
116
|
-
|
|
117
|
-
await preuninstall.runPreUninstall()
|
|
118
|
-
const containsAlias = await helpers.fileContains(TEST_PROFILE_PATH, TEST_ALIAS)
|
|
119
|
-
expect(containsAlias).toBe(true)
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
test('uninstall handles empty profile', async () => {
|
|
123
|
-
await preuninstall.runPreUninstall()
|
|
124
|
-
|
|
125
|
-
const profileExists = await fs.promises
|
|
126
|
-
.access(TEST_PROFILE_PATH, fs.constants.F_OK)
|
|
127
|
-
.then(() => true)
|
|
128
|
-
.catch(() => false)
|
|
129
|
-
expect(profileExists).toBe(false)
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
describe('getShellConfig', () => {
|
|
133
|
-
test('detects bash', () => {
|
|
134
|
-
mockGetShellConfig.mockRestore()
|
|
135
|
-
process.env.SHELL = '/bin/bash'
|
|
136
|
-
const { name } = helpers.getShellConfig()
|
|
137
|
-
expect(name).toBe('bash')
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
test('detects zsh', () => {
|
|
141
|
-
mockGetShellConfig.mockRestore()
|
|
142
|
-
process.env.SHELL = '/usr/bin/zsh'
|
|
143
|
-
const { name } = helpers.getShellConfig()
|
|
144
|
-
expect(name).toBe('zsh')
|
|
145
|
-
})
|
|
146
|
-
})
|