@beauraines/bacon-ipsum-cli 0.1.3 → 0.1.5

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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.1.5](https://github.com/beauraines/bacon-ipsum-cli/compare/v0.1.4...v0.1.5) (2024-05-27)
6
+
7
+
8
+ ### Features
9
+
10
+ * adds support for more options ([#4](https://github.com/beauraines/bacon-ipsum-cli/issues/4)) ([4b9f87e](https://github.com/beauraines/bacon-ipsum-cli/commit/4b9f87e2971868cd15f92ca632571ec7d245aa94))
11
+
12
+ ### [0.1.4](https://github.com/beauraines/bacon-ipsum-cli/compare/v0.1.3...v0.1.4) (2024-05-27)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * bad merge in eslint ([7c34b5d](https://github.com/beauraines/bacon-ipsum-cli/commit/7c34b5d24f6d4bcb4445e4a6fc9271a55a7c5d4d))
18
+
5
19
  ### 0.1.3 (2024-05-26)
6
20
 
7
21
 
package/TODO.md CHANGED
@@ -1,7 +1,11 @@
1
1
  # TODO
2
2
 
3
3
  - [ ] Move API call to module for testing
4
- - [ ] Add other options
5
- - [ ] Add debug
4
+ - [x] Add other options
5
+ - [x] Add debug
6
6
  - [ ] Add unit tests
7
7
  - [ ] Add completion command
8
+ - [x] Configure linter - 'dont warn for Node globals like console'
9
+ - [x] Swith to ESM and import latest versions of dependencies
10
+ - [ ] Add README
11
+ - [ ] Add output options (format and clipboard)
package/cli.js CHANGED
@@ -1,13 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const fetch = require('node-fetch');
4
- const yargs = require('yargs');
5
- const copyPaste = require('copy-paste');
3
+ import fetch from "node-fetch";
4
+ import yargs from "yargs";
5
+ import copyPaste from "copy-paste";
6
+ import debugClient from 'debug'
7
+ import { buildQueryString } from './utils.js';
6
8
 
9
+
10
+ const debug = debugClient('bacon-ipsum-cli');
7
11
  const apiUrl = 'https://baconipsum.com/api/';
8
12
 
9
13
  // Define command-line options using yargs
10
- const argv = yargs
14
+ const argv = yargs(process.argv.slice(2))
11
15
  .scriptName('bacon')
12
16
  .option('type', {
13
17
  alias: 't',
@@ -21,16 +25,16 @@ const argv = yargs
21
25
  default: 1,
22
26
  type: 'number',
23
27
  })
24
- // .option('sentences',{
25
- // alias: 's',
26
- // describe: 'Number of sentences. This overrides paragraphs.',
27
- // type: 'number'
28
- // })
29
- // .option('start-with-lorem',{
30
- // alias: ['l','lorem'],
31
- // describe: 'Starts the first paragraph with ‘Bacon ipsum dolor sit amet’',
32
- // type: 'boolean'
33
- // })
28
+ .option('sentences',{
29
+ alias: 's',
30
+ describe: 'Number of sentences. This overrides paragraphs.',
31
+ type: 'number'
32
+ })
33
+ .option('start-with-lorem',{
34
+ alias: ['l','lorem'],
35
+ describe: 'Starts the first paragraph with ‘Bacon ipsum dolor sit amet’',
36
+ type: 'boolean'
37
+ })
34
38
  // .option('format',{
35
39
  // alias: 'f',
36
40
  // describe:'Output format. Defaults to `text`',
@@ -44,10 +48,10 @@ const argv = yargs
44
48
  // })
45
49
  .help()
46
50
  .argv;
47
-
48
- // Build the API URL with the specified options
49
- // TODO support additional parameters
50
- const apiUrlWithParams = `${apiUrl}?type=${argv.type}&paras=${argv.paras}`;
51
+
52
+ debug(argv)
53
+ const apiUrlWithParams = `${apiUrl}?${buildQueryString(argv)}`
54
+ debug(apiUrlWithParams)
51
55
 
52
56
  // Fetch data from the Bacon Ipsum API
53
57
  fetch(apiUrlWithParams)
package/eslint.config.mjs CHANGED
@@ -1,21 +1,20 @@
1
1
  import globals from "globals";
2
2
  import pluginJs from "@eslint/js";
3
- import jest from "eslint-plugin-jest";
3
+ import jestPlugin from "eslint-plugin-jest";
4
4
 
5
5
  export default [
6
- { files: ["**/*.js"], languageOptions: { sourceType: "commonjs" } },
7
- { languageOptions: { globals: globals.browser } },
6
+ {
7
+ files: ["**/*.js"],
8
+ languageOptions: { sourceType: "module", ecmaVersion: "latest", globals: globals.nodeBuiltin}
9
+ },
10
+ { languageOptions: { ...jestPlugin.environments.globals } },
8
11
  pluginJs.configs.recommended,
9
12
  {
10
13
  plugins: {
11
- jest: jest
14
+ jest: jestPlugin
12
15
  },
13
16
  rules: {
14
- "jest/no-disabled-tests": "warn",
15
- "jest/no-focused-tests": "error",
16
- "jest/no-identical-title": "error",
17
- "jest/prefer-to-have-length": "warn",
18
- "jest/valid-expect": "error"
17
+ ...jestPlugin.configs.recommended.rules, // Use recommended rules from eslint-plugin-jest
19
18
  }
20
19
  }
21
20
  ];
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@beauraines/bacon-ipsum-cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "CLI for Bacon Ipsum text",
5
- "main": "cli.js",
5
+ "exports": "./cli.js",
6
+ "type": "module",
6
7
  "bin": {
7
8
  "bacon-ipsum": "cli.js"
8
9
  },
@@ -19,13 +20,15 @@
19
20
  "chalk": "^4.1.2",
20
21
  "copy-paste": "^1.5.3",
21
22
  "node-fetch": "^2.6.7",
23
+ "query-string": "^9.0.0",
22
24
  "yargs": "^17.7.2"
23
25
  },
24
26
  "devDependencies": {
25
27
  "@eslint/js": "^9.3.0",
28
+ "debug": "^4.3.4",
26
29
  "eslint": "^9.3.0",
27
- "globals": "^15.3.0",
28
30
  "eslint-plugin-jest": "^28.5.0",
31
+ "globals": "^15.3.0",
29
32
  "jest": "^29.7.0",
30
33
  "should-release": "^1.2.0",
31
34
  "standard-version": "^9.5.0"
package/utils.js ADDED
@@ -0,0 +1,16 @@
1
+ import queryString from "query-string";
2
+ import debugClient from 'debug'
3
+ const debug = debugClient('bacon-ipsum-cli-utils');
4
+
5
+ export const buildQueryString = (argv) => {
6
+ // Build the API URL with the specified options
7
+ let queryParams = {
8
+ type: argv.type,
9
+ paras: argv.paras,
10
+ sentences: argv.sentences,
11
+ "start-with-lorem" : argv['start-with-lorem'] ? 1 : null
12
+ }
13
+ const qs = queryString.stringify(queryParams);
14
+ debug(qs)
15
+ return qs
16
+ }