@beauraines/bacon-ipsum-cli 0.1.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/.github/dependabot.yml +21 -0
- package/.github/workflows/main.yml +27 -0
- package/.github/workflows/publish.yml +54 -0
- package/LICENSE +21 -0
- package/TODO.md +7 -0
- package/cli.js +64 -0
- package/cli.test.js +24 -0
- package/eslint.config.mjs +21 -0
- package/package.json +33 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "npm" # See documentation for possible values
|
|
9
|
+
directory: "/" # Location of package manifests
|
|
10
|
+
schedule:
|
|
11
|
+
interval: "weekly"
|
|
12
|
+
day: "friday"
|
|
13
|
+
commit-message:
|
|
14
|
+
prefix: fix
|
|
15
|
+
prefix-development: chore
|
|
16
|
+
include: scope
|
|
17
|
+
groups:
|
|
18
|
+
dev-dependencies:
|
|
19
|
+
dependency-type: "development"
|
|
20
|
+
patterns:
|
|
21
|
+
- "*"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Node.js CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
strategy:
|
|
16
|
+
matrix:
|
|
17
|
+
node-version: [18.x,20.x]
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v3
|
|
21
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
22
|
+
uses: actions/setup-node@v3
|
|
23
|
+
with:
|
|
24
|
+
node-version: ${{ matrix.node-version }}
|
|
25
|
+
- run: npm ci
|
|
26
|
+
- run: npm run build --if-present
|
|
27
|
+
- run: npm test
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: 'Publish to NPM'
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_run:
|
|
5
|
+
workflows: ['Node.js CI']
|
|
6
|
+
types: [completed]
|
|
7
|
+
branches: [master,main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
publish-new-version:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v3
|
|
15
|
+
with:
|
|
16
|
+
fetch-depth: '0'
|
|
17
|
+
- name: git setup
|
|
18
|
+
run: |
|
|
19
|
+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
20
|
+
git config --local user.name "github-actions[bot]"
|
|
21
|
+
- name: setup node
|
|
22
|
+
uses: actions/setup-node@v3
|
|
23
|
+
with:
|
|
24
|
+
node-version: 16.x
|
|
25
|
+
registry-url: 'https://registry.npmjs.org'
|
|
26
|
+
- name: npm install
|
|
27
|
+
run: npm ci
|
|
28
|
+
|
|
29
|
+
- name: Should release
|
|
30
|
+
id: should_release
|
|
31
|
+
continue-on-error: true
|
|
32
|
+
run: npm run should-release -- -v
|
|
33
|
+
|
|
34
|
+
- name: No release
|
|
35
|
+
if: steps.should_release.outcome != 'success'
|
|
36
|
+
run: echo "No release required. Skipping publishing."
|
|
37
|
+
|
|
38
|
+
- name: Version bump
|
|
39
|
+
if: steps.should_release.outcome == 'success'
|
|
40
|
+
run: npm run release
|
|
41
|
+
|
|
42
|
+
- name: Publish to NPM
|
|
43
|
+
if: steps.should_release.outcome == 'success'
|
|
44
|
+
run: npm publish
|
|
45
|
+
env:
|
|
46
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
47
|
+
|
|
48
|
+
- name: Push commits to GitHub
|
|
49
|
+
if: steps.should_release.outcome == 'success'
|
|
50
|
+
uses: ad-m/github-push-action@master
|
|
51
|
+
with:
|
|
52
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
53
|
+
branch: ${{ github.ref }}
|
|
54
|
+
tags: true
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Beau Raines
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/TODO.md
ADDED
package/cli.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fetch = require('node-fetch');
|
|
4
|
+
const yargs = require('yargs');
|
|
5
|
+
const copyPaste = require('copy-paste');
|
|
6
|
+
|
|
7
|
+
const apiUrl = 'https://baconipsum.com/api/';
|
|
8
|
+
|
|
9
|
+
// Define command-line options using yargs
|
|
10
|
+
const argv = yargs
|
|
11
|
+
.scriptName('bacon')
|
|
12
|
+
.option('type', {
|
|
13
|
+
alias: 't',
|
|
14
|
+
describe: 'Type of meat',
|
|
15
|
+
default: 'all-meat',
|
|
16
|
+
choices: ['all-meat', 'meat-and-filler'],
|
|
17
|
+
})
|
|
18
|
+
.option('paras', {
|
|
19
|
+
alias: 'p',
|
|
20
|
+
describe: 'Number of paragraphs',
|
|
21
|
+
default: 1,
|
|
22
|
+
type: 'number',
|
|
23
|
+
})
|
|
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
|
+
// })
|
|
34
|
+
// .option('format',{
|
|
35
|
+
// alias: 'f',
|
|
36
|
+
// describe:'Output format. Defaults to `text`',
|
|
37
|
+
// default: 'text',
|
|
38
|
+
// choices: ['text','json','html']
|
|
39
|
+
// })
|
|
40
|
+
// .option('no-clip',{
|
|
41
|
+
// alias: 'nc',
|
|
42
|
+
// describe:'Only outputs to console, bypassing the clipboard.',
|
|
43
|
+
// type: 'boolean'
|
|
44
|
+
// })
|
|
45
|
+
.help()
|
|
46
|
+
.argv;
|
|
47
|
+
|
|
48
|
+
// Build the API URL with the specified options
|
|
49
|
+
// TODO support additional parameters
|
|
50
|
+
const apiUrlWithParams = `${apiUrl}?type=${argv.type}¶s=${argv.paras}`;
|
|
51
|
+
|
|
52
|
+
// Fetch data from the Bacon Ipsum API
|
|
53
|
+
fetch(apiUrlWithParams)
|
|
54
|
+
.then((response) => response.json())
|
|
55
|
+
.then((data) => {
|
|
56
|
+
// Display the fetched text in the console
|
|
57
|
+
console.log(data.join('\n'));
|
|
58
|
+
|
|
59
|
+
// Copy the text to the clipboard
|
|
60
|
+
copyPaste.copy(data.join('\n'), () => {
|
|
61
|
+
console.log('Text copied to clipboard!');
|
|
62
|
+
});
|
|
63
|
+
})
|
|
64
|
+
.catch((error) => console.error('Error fetching data:', error));
|
package/cli.test.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const { describe, expect, it } = require('jest');
|
|
2
|
+
|
|
3
|
+
describe('utilities', () => {
|
|
4
|
+
it('should return multiple paragraphs', () => {
|
|
5
|
+
const paragraphs = 2;
|
|
6
|
+
// Make API call, capture output
|
|
7
|
+
const output = `Turkey flank meatball, ham t-bone pancetta ham hock drumstick beef boudin ground round short loin pig buffalo. Flank pork pork loin chislic spare ribs. Pork loin tenderloin kevin, bresaola picanha ham hock shoulder shank venison rump. Shankle short loin fatback venison salami. Capicola short ribs landjaeger, beef ribs shankle bacon meatloaf sirloin frankfurter venison chicken ham hock burgdoggen chuck. Burgdoggen tri-tip salami beef shoulder boudin flank andouille pancetta tongue fatback short ribs t-bone.
|
|
8
|
+
Tongue venison ham tri-tip. Pig porchetta bacon, kielbasa pork chop spare ribs turducken landjaeger brisket. Capicola chicken pancetta short ribs kevin tenderloin, alcatra fatback beef ribs. Beef spare ribs sirloin fatback, rump burgdoggen doner ham beef ribs leberkas jowl shankle shank.`;
|
|
9
|
+
let newLineCount = output.split(/\n/).length
|
|
10
|
+
expect(newLineCount).toBe(paragraphs)
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it.skip('should return an empty array without input', () => {
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it.skip('should return the undefined if there is no data property', () => {
|
|
17
|
+
const input = { some: 'random', object: { with: ['nested', 'array'] } };
|
|
18
|
+
const output = mapData(input);
|
|
19
|
+
expect(output).to.be.undefined;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it.skip('should return the data property if passed an object with data', () => {
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import globals from "globals";
|
|
2
|
+
import pluginJs from "@eslint/js";
|
|
3
|
+
import jest from "eslint-plugin-jest";
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
{ files: ["**/*.js"], languageOptions: { sourceType: "commonjs" } },
|
|
7
|
+
{ languageOptions: { globals: globals.browser } },
|
|
8
|
+
pluginJs.configs.recommended,
|
|
9
|
+
{
|
|
10
|
+
plugins: {
|
|
11
|
+
jest: jest
|
|
12
|
+
},
|
|
13
|
+
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"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
];
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@beauraines/bacon-ipsum-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "CLI for Bacon Ipsum text",
|
|
5
|
+
"main": "cli.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"bacon-ipsum": "cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "jest --passWithNoTests",
|
|
11
|
+
"lint": "eslint . ./**/*.js ./**/*.mjs",
|
|
12
|
+
"lint:fix": "eslint . ./**/*.js ./**/*.mjs --fix",
|
|
13
|
+
"release": "standard-version",
|
|
14
|
+
"should-release": "should-release"
|
|
15
|
+
},
|
|
16
|
+
"author": "Beau Raines",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"chalk": "^4.1.2",
|
|
20
|
+
"copy-paste": "^1.5.3",
|
|
21
|
+
"node-fetch": "^2.6.7",
|
|
22
|
+
"yargs": "^17.7.2"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@eslint/js": "^9.3.0",
|
|
26
|
+
"eslint": "^9.3.0",
|
|
27
|
+
"globals": "^15.3.0",
|
|
28
|
+
"eslint-plugin-jest": "^28.5.0",
|
|
29
|
+
"jest": "^29.7.0",
|
|
30
|
+
"should-release": "^1.2.0",
|
|
31
|
+
"standard-version": "^9.5.0"
|
|
32
|
+
}
|
|
33
|
+
}
|