@localnerve/get-attribute 3.9.0 → 4.0.1
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/.nvmrc +1 -0
- package/README.md +2 -0
- package/bin/get-attribute +1 -1
- package/lib/cli.js +7 -7
- package/lib/get-attribute.js +6 -6
- package/lib/index.js +2 -2
- package/package.json +11 -10
- package/eslint.config.js +0 -40
- package/jest.config.js +0 -17
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
20.19
|
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|

|
|
7
7
|
[](https://coveralls.io/github/localnerve/get-attribute?branch=main)
|
|
8
8
|
|
|
9
|
+
> See [repo releases](https://github.com/localnerve/get-attribute/releases) for change notes
|
|
10
|
+
|
|
9
11
|
## Example
|
|
10
12
|
|
|
11
13
|
Grab the full url from a specific anchor tag of interest (all options shown):
|
package/bin/get-attribute
CHANGED
package/lib/cli.js
CHANGED
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
* Copyright (c) 2025, Alex Grant <alex@localNerve.com> (https://www.localnerve.com)
|
|
7
7
|
* Licensed under the MIT license.
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
import yargs from 'yargs';
|
|
10
|
+
import { hideBin } from 'yargs/helpers';
|
|
11
|
+
import debugLib from '@localnerve/debug';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
const debug = debugLib('cli');
|
|
14
|
+
|
|
15
|
+
export default function getCommandLineArgs (argv) {
|
|
14
16
|
debug('process argv', argv);
|
|
15
17
|
|
|
16
18
|
const args = yargs(hideBin(argv)).argv;
|
|
@@ -52,6 +54,4 @@ function getCommandLineArgs (argv) {
|
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
return args;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
module.exports = getCommandLineArgs;
|
|
57
|
+
}
|
package/lib/get-attribute.js
CHANGED
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
* Copyright (c) 2025, Alex Grant <alex@localNerve.com> (https://www.localnerve.com)
|
|
5
5
|
* Licensed under the MIT license.
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import { default as puppeteer, TimeoutError } from 'puppeteer';
|
|
8
|
+
import debugLib from '@localnerve/debug';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const debug = debugLib('get-attribute');
|
|
11
|
+
|
|
12
|
+
export default async function getAttribute (url, selector, attribute, {
|
|
11
13
|
useProp = false,
|
|
12
14
|
timeout = 10000,
|
|
13
15
|
launchArgs = {}
|
|
@@ -60,6 +62,4 @@ async function getAttribute (url, selector, attribute, {
|
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
return attributeValue;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
module.exports = getAttribute;
|
|
65
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* Copyright (c) 2025, Alex Grant <alex@localNerve.com> (https://www.localnerve.com)
|
|
7
7
|
* Licensed under the MIT license.
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
import getArgs from './cli.js';
|
|
10
|
+
import getAttr from './get-attribute.js';
|
|
11
11
|
|
|
12
12
|
const syntax = 'get-attribute --url=https://host.dom --selector=a[href^="/videos"] --attribute=href [--useprop=false] [--timeout=10000] [--launchargs=\'{"json":true}\']';
|
|
13
13
|
const args = getArgs(process.argv);
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@localnerve/get-attribute",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Get an attribute from a webpage, echo to stdout",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "lib/index.js",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"lint": "eslint .",
|
|
@@ -28,20 +29,20 @@
|
|
|
28
29
|
},
|
|
29
30
|
"homepage": "https://github.com/localnerve/get-attribute#readme",
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"puppeteer": "^24.
|
|
32
|
-
"yargs": "^
|
|
33
|
-
"debug": "^
|
|
32
|
+
"puppeteer": "^24.10.1",
|
|
33
|
+
"yargs": "^18.0.0",
|
|
34
|
+
"@localnerve/debug": "^1.0.5"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"eslint": "^9.
|
|
37
|
-
"@eslint/js": "^9.
|
|
38
|
-
"eslint-plugin-jest": "^28.
|
|
37
|
+
"eslint": "^9.28.0",
|
|
38
|
+
"@eslint/js": "^9.28.0",
|
|
39
|
+
"eslint-plugin-jest": "^28.13.3",
|
|
39
40
|
"express": "^5.1.0",
|
|
40
|
-
"globals": "^16.
|
|
41
|
-
"jest": "^
|
|
41
|
+
"globals": "^16.2.0",
|
|
42
|
+
"jest": "^30.0.0",
|
|
42
43
|
"server-destroy": "^1.0.1"
|
|
43
44
|
},
|
|
44
45
|
"engines": {
|
|
45
|
-
"node": ">=
|
|
46
|
+
"node": "^20.19.0 || ^22.12.0 || >=23"
|
|
46
47
|
}
|
|
47
48
|
}
|
package/eslint.config.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
const js = require('@eslint/js');
|
|
2
|
-
const globals = require('globals');
|
|
3
|
-
const jest = require('eslint-plugin-jest');
|
|
4
|
-
|
|
5
|
-
const ignores = {
|
|
6
|
-
name: 'ignores',
|
|
7
|
-
ignores: [
|
|
8
|
-
'bin/**',
|
|
9
|
-
'node_modules/**',
|
|
10
|
-
'tmp/**',
|
|
11
|
-
'coverage/**'
|
|
12
|
-
]
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const tests = {
|
|
16
|
-
name: 'tests',
|
|
17
|
-
files: ['__tests__/**'],
|
|
18
|
-
...jest.configs['flat/recommended']
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const lib = {
|
|
22
|
-
name: 'lib',
|
|
23
|
-
files: ['lib/**'],
|
|
24
|
-
languageOptions: {
|
|
25
|
-
globals: {
|
|
26
|
-
...globals.node
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
rules: {
|
|
30
|
-
...js.configs.recommended.rules,
|
|
31
|
-
indent: [2, 2, {
|
|
32
|
-
SwitchCase: 1,
|
|
33
|
-
MemberExpression: 1
|
|
34
|
-
}],
|
|
35
|
-
quotes: [2, 'single'],
|
|
36
|
-
'dot-notation': [2, {allowKeywords: true}]
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
module.exports = [ignores, tests, lib];
|
package/jest.config.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
collectCoverage: true,
|
|
3
|
-
coverageDirectory: 'coverage',
|
|
4
|
-
coveragePathIgnorePatterns: [
|
|
5
|
-
'/__tests__/globals/'
|
|
6
|
-
],
|
|
7
|
-
globalSetup: './__tests__/globals/setup',
|
|
8
|
-
globalTeardown: './__tests__/globals/teardown',
|
|
9
|
-
verbose: true,
|
|
10
|
-
testEnvironment: 'node',
|
|
11
|
-
testPathIgnorePatterns: [
|
|
12
|
-
'/node_modules/',
|
|
13
|
-
'/tmp/',
|
|
14
|
-
'__tests__/fixtures',
|
|
15
|
-
'__tests__/globals'
|
|
16
|
-
]
|
|
17
|
-
};
|