@beauraines/rtm-cli 1.5.8 → 1.6.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/.eslintrc.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "env": {
3
+ "browser": true,
4
+ "commonjs": true,
5
+ "es2021": true
6
+ },
7
+ "extends": "eslint:recommended",
8
+ "overrides": [
9
+ ],
10
+ "parserOptions": {
11
+ "ecmaVersion": "latest"
12
+ },
13
+ "rules": {
14
+ }
15
+ }
@@ -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
@@ -0,0 +1,25 @@
1
+ name: Node.js CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ build:
11
+
12
+ runs-on: ubuntu-latest
13
+
14
+ strategy:
15
+ matrix:
16
+ node-version: [16.x,18.x]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v3
20
+ - name: Use Node.js ${{ matrix.node-version }}
21
+ uses: actions/setup-node@v3
22
+ with:
23
+ node-version: ${{ matrix.node-version }}
24
+ - run: npm ci
25
+ - run: npm test
package/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+
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
+
5
+ ## [1.6.0](https://github.com/beauraines/rtm-cli/compare/v1.5.1...v1.6.0) (2023-03-05)
6
+
7
+
8
+ ### Features
9
+
10
+ * Display the full task information ([#22](https://github.com/beauraines/rtm-cli/issues/22)) ([c5f1b1a](https://github.com/beauraines/rtm-cli/commit/c5f1b1ac9734decf557005f49294c8030658d105)), closes [#17](https://github.com/beauraines/rtm-cli/issues/17)
package/jest.config.js ADDED
@@ -0,0 +1,195 @@
1
+ /*
2
+ * For a detailed explanation regarding each configuration property, visit:
3
+ * https://jestjs.io/docs/configuration
4
+ */
5
+
6
+ module.exports = {
7
+ // All imported modules in your tests should be mocked automatically
8
+ // automock: false,
9
+
10
+ // Stop running tests after `n` failures
11
+ // bail: 0,
12
+
13
+ // The directory where Jest should store its cached dependency information
14
+ // cacheDirectory: "/private/var/folders/8s/3xlngh6x3734dvdvgk4235_r0000gp/T/jest_dy",
15
+
16
+ // Automatically clear mock calls, instances, contexts and results before every test
17
+ // clearMocks: false,
18
+
19
+ // Indicates whether the coverage information should be collected while executing the test
20
+ collectCoverage: true,
21
+
22
+ // An array of glob patterns indicating a set of files for which coverage information should be collected
23
+ // collectCoverageFrom: undefined,
24
+
25
+ // The directory where Jest should output its coverage files
26
+ coverageDirectory: "coverage",
27
+
28
+ // An array of regexp pattern strings used to skip coverage collection
29
+ // coveragePathIgnorePatterns: [
30
+ // "/node_modules/"
31
+ // ],
32
+
33
+ // Indicates which provider should be used to instrument code for coverage
34
+ coverageProvider: "v8",
35
+
36
+ // A list of reporter names that Jest uses when writing coverage reports
37
+ // coverageReporters: [
38
+ // "json",
39
+ // "text",
40
+ // "lcov",
41
+ // "clover"
42
+ // ],
43
+
44
+ // An object that configures minimum threshold enforcement for coverage results
45
+ // coverageThreshold: undefined,
46
+
47
+ // A path to a custom dependency extractor
48
+ // dependencyExtractor: undefined,
49
+
50
+ // Make calling deprecated APIs throw helpful error messages
51
+ // errorOnDeprecated: false,
52
+
53
+ // The default configuration for fake timers
54
+ // fakeTimers: {
55
+ // "enableGlobally": false
56
+ // },
57
+
58
+ // Force coverage collection from ignored files using an array of glob patterns
59
+ // forceCoverageMatch: [],
60
+
61
+ // A path to a module which exports an async function that is triggered once before all test suites
62
+ // globalSetup: undefined,
63
+
64
+ // A path to a module which exports an async function that is triggered once after all test suites
65
+ // globalTeardown: undefined,
66
+
67
+ // A set of global variables that need to be available in all test environments
68
+ // globals: {},
69
+
70
+ // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
71
+ // maxWorkers: "50%",
72
+
73
+ // An array of directory names to be searched recursively up from the requiring module's location
74
+ // moduleDirectories: [
75
+ // "node_modules"
76
+ // ],
77
+
78
+ // An array of file extensions your modules use
79
+ // moduleFileExtensions: [
80
+ // "js",
81
+ // "mjs",
82
+ // "cjs",
83
+ // "jsx",
84
+ // "ts",
85
+ // "tsx",
86
+ // "json",
87
+ // "node"
88
+ // ],
89
+
90
+ // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
91
+ // moduleNameMapper: {},
92
+
93
+ // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
94
+ // modulePathIgnorePatterns: [],
95
+
96
+ // Activates notifications for test results
97
+ // notify: false,
98
+
99
+ // An enum that specifies notification mode. Requires { notify: true }
100
+ // notifyMode: "failure-change",
101
+
102
+ // A preset that is used as a base for Jest's configuration
103
+ // preset: undefined,
104
+
105
+ // Run tests from one or more projects
106
+ // projects: undefined,
107
+
108
+ // Use this configuration option to add custom reporters to Jest
109
+ // reporters: undefined,
110
+
111
+ // Automatically reset mock state before every test
112
+ // resetMocks: false,
113
+
114
+ // Reset the module registry before running each individual test
115
+ // resetModules: false,
116
+
117
+ // A path to a custom resolver
118
+ // resolver: undefined,
119
+
120
+ // Automatically restore mock state and implementation before every test
121
+ // restoreMocks: false,
122
+
123
+ // The root directory that Jest should scan for tests and modules within
124
+ // rootDir: undefined,
125
+
126
+ // A list of paths to directories that Jest should use to search for files in
127
+ // roots: [
128
+ // "<rootDir>"
129
+ // ],
130
+
131
+ // Allows you to use a custom runner instead of Jest's default test runner
132
+ // runner: "jest-runner",
133
+
134
+ // The paths to modules that run some code to configure or set up the testing environment before each test
135
+ // setupFiles: [],
136
+
137
+ // A list of paths to modules that run some code to configure or set up the testing framework before each test
138
+ // setupFilesAfterEnv: [],
139
+
140
+ // The number of seconds after which a test is considered as slow and reported as such in the results.
141
+ // slowTestThreshold: 5,
142
+
143
+ // A list of paths to snapshot serializer modules Jest should use for snapshot testing
144
+ // snapshotSerializers: [],
145
+
146
+ // The test environment that will be used for testing
147
+ // testEnvironment: "jest-environment-node",
148
+
149
+ // Options that will be passed to the testEnvironment
150
+ // testEnvironmentOptions: {},
151
+
152
+ // Adds a location field to test results
153
+ // testLocationInResults: false,
154
+
155
+ // The glob patterns Jest uses to detect test files
156
+ // testMatch: [
157
+ // "**/__tests__/**/*.[jt]s?(x)",
158
+ // "**/?(*.)+(spec|test).[tj]s?(x)"
159
+ // ],
160
+
161
+ // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
162
+ // testPathIgnorePatterns: [
163
+ // "/node_modules/"
164
+ // ],
165
+
166
+ // The regexp pattern or array of patterns that Jest uses to detect test files
167
+ // testRegex: [],
168
+
169
+ // This option allows the use of a custom results processor
170
+ // testResultsProcessor: undefined,
171
+
172
+ // This option allows use of a custom test runner
173
+ // testRunner: "jest-circus/runner",
174
+
175
+ // A map from regular expressions to paths to transformers
176
+ // transform: undefined,
177
+
178
+ // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
179
+ // transformIgnorePatterns: [
180
+ // "/node_modules/",
181
+ // "\\.pnp\\.[^\\/]+$"
182
+ // ],
183
+
184
+ // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
185
+ // unmockedModulePathPatterns: undefined,
186
+
187
+ // Indicates whether each individual test should be reported during the run
188
+ verbose: true,
189
+
190
+ // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
191
+ // watchPathIgnorePatterns: [],
192
+
193
+ // Whether to use watchman for file crawling
194
+ // watchman: true,
195
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beauraines/rtm-cli",
3
- "version": "1.5.8",
3
+ "version": "1.6.0",
4
4
  "description": "RTM CLI",
5
5
  "keywords": [
6
6
  "rtm",
@@ -18,7 +18,12 @@
18
18
  "main": "src/utils/index.js",
19
19
  "scripts": {
20
20
  "postversion": "npm run build",
21
- "build": "node build.js"
21
+ "build": "node build.js",
22
+ "test": "jest --passWithNoTests",
23
+ "lint": "eslint src",
24
+ "lintfix": "eslint src --fix",
25
+ "release": "standard-version",
26
+ "should-release": "should-release"
22
27
  },
23
28
  "repository": {
24
29
  "type": "git",
@@ -33,26 +38,31 @@
33
38
  "dependencies": {
34
39
  "@beauraines/rtm-api": "^1.4.1",
35
40
  "chalk": "^2.3.0",
36
- "cli-table3": "^0.5.0",
37
- "commander": "^2.11.0",
41
+ "cli-table3": "^0.6.3",
42
+ "commander": "^10.0.0",
38
43
  "copy-paste": "^1.3.0",
39
44
  "dateformat": "^3.0.2",
40
45
  "deepmerge": "^2.0.1",
41
46
  "opn": "^5.4.0",
42
47
  "ora": "^1.3.0",
43
48
  "prompt-sync": "^4.2.0",
49
+ "should-release": "^1.2.0",
50
+ "standard-version": "^9.5.0",
44
51
  "window-size": "^1.1.0"
45
52
  },
46
53
  "devDependencies": {
47
54
  "archiver": "^2.1.0",
48
- "pkg": "^4.3.3"
55
+ "eslint": "^8.34.0",
56
+ "eslint-plugin-jest": "^27.2.1",
57
+ "jest": "^29.4.3",
58
+ "pkg": "^5.8.0"
49
59
  },
50
60
  "pkg": {
51
61
  "scripts": [
52
62
  "config.json",
53
63
  "src/cmd/*.js"
54
64
  ],
55
- "targets": "node8-linux-x86,node8-linux-x64,node8-macos-x86,node8-macos-x64,node8-win-x86,node8-win-x64",
65
+ "targets": "latest-linux-x64,latest-macos-x64,latest-win-x64",
56
66
  "out": "./bin"
57
67
  }
58
68
  }
@@ -0,0 +1,116 @@
1
+ 'use strict';
2
+
3
+ const log = require('../utils/log.js');
4
+ const config = require('../utils/config.js');
5
+ const finish = require('../utils/finish.js');
6
+ const filter = require('../utils/filter');
7
+ const { indexPrompt } = require('../utils/prompt')
8
+
9
+
10
+ let TASKS = [];
11
+
12
+ // Get Display Styles
13
+ let styles = config.get().styles;
14
+
15
+ /**
16
+ * This command displays all task details
17
+ * @param args index
18
+ * @param env
19
+ */
20
+ async function action(args, env) {
21
+
22
+ // Reset TASKS
23
+ TASKS = [];
24
+
25
+ const user = config.user(user => user)
26
+
27
+ let indices = []
28
+
29
+ // Prompt for task
30
+ if ( args.length < 1 ) {
31
+ indices = indexPrompt('Task:')
32
+ args[0] = indices
33
+ }
34
+
35
+
36
+ log.spinner.start("Getting Task(s)");
37
+ // Use provided args
38
+ for (const arg in args[0]) {
39
+ if (Object.hasOwnProperty.call(args[0], arg)) {
40
+ const index = args[0][arg];
41
+ const filterString = filter();
42
+ let task = await user.tasks.rtmIndexFetchTask(index,filterString)
43
+ if (task.err == undefined ) {
44
+ task = task.task
45
+ } else {
46
+ log.spinner.warn('Task #' + index + ' is not found');
47
+ }
48
+
49
+ // Push to TASKS
50
+ TASKS.push({
51
+ index: index,
52
+ task
53
+ });
54
+
55
+ }
56
+ }
57
+ // Print TASKS
58
+ log.spinner.stop();
59
+ for ( let i = 0; i < TASKS.length; i++ ) {
60
+ displayTask(TASKS[i]);
61
+ }
62
+
63
+
64
+ finish()
65
+
66
+
67
+ }
68
+
69
+
70
+ module.exports = {
71
+ command: 'task [indices...]',
72
+ options: [],
73
+ description: 'Display the Task details',
74
+ action: action
75
+ };
76
+
77
+ function displayTask(taskDetails) {
78
+ let index = taskDetails.index;
79
+ // eslint-disable-next-line no-unused-vars
80
+ const { _list, list_id, taskseries_id, task_id, _index, name, priority, start, due, completed, isRecurring, isSubtask, estimate, url, tags, notes ,...otherAttributes } = taskDetails.task;
81
+ log.style(index + " " + name,styles.list,true);
82
+ log.style(`List: `,styles.index)
83
+ log(`${list_id}`) // TODO lookup the list name
84
+ log.style(`Priority: `,styles.index)
85
+ log.style(`${priority}`,styles.priority[priority],true)
86
+ log.style(`Start: `,styles.index)
87
+ log(`${start}`)
88
+ log.style(`Due: `,styles.index)
89
+ log(`${due}`)
90
+ log.style(`Completed: `,styles.index)
91
+ log(`${completed}`)
92
+ log.style(`Is Recurring: `,styles.index)
93
+ log(`${isRecurring}`)
94
+ log.style(`Is Subtask: `,styles.index)
95
+ log(`${isSubtask}`)
96
+ log.style(`Estimate: `,styles.index)
97
+ log(`${estimate}`)
98
+ log.style(`Url: `,styles.index)
99
+ log(`${url}`)
100
+ log.style(`Tags: `,styles.index)
101
+ log.style(`${tags}`,styles.tags, true)
102
+ log.style(`Notes: `,styles.index)
103
+ for (const note of notes) {
104
+ log.style(note.title ? note.title : '',true);
105
+ log('========');
106
+ log(note.body);
107
+ log();
108
+ }
109
+
110
+ // Displays all the other attributes. This will allow more attributes to be added to a RTMTask and they'll still be displayed.
111
+ for (const [key, value] of Object.entries(otherAttributes)) {
112
+ log.style(`${key}: `, styles.index, false);
113
+ log(`${value}`);
114
+ }
115
+ log()
116
+ }