imdone-core 2.0.10 → 2.0.12

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/.env ADDED
@@ -0,0 +1,6 @@
1
+
2
+ # Jira environment variables
3
+
4
+ # JIRA_AUTH_BASIC=true # Set to false to use Bearer token auth.
5
+ # JIRA_USERNAME="<your jira username>" # e.g. your email address. Not needed if using Bearer token auth.
6
+ # JIRA_TOKEN="<your personal access token>"
@@ -1,5 +1,3 @@
1
- import { info, error as consoleError, warn as consoleWarn } from 'console'
2
-
3
1
  // Log levels with numeric values for comparison
4
2
  const LogLevel = {
5
3
  ERROR: 0,
@@ -10,7 +8,7 @@ const LogLevel = {
10
8
  NONE: -1 // Use this to disable all logging
11
9
  }
12
10
 
13
- function getCallerInfo() {
11
+ export function getCallerInfo() {
14
12
  const err = new Error();
15
13
  const stack = err.stack?.split('\n');
16
14
 
@@ -47,10 +45,13 @@ function getCallerInfo() {
47
45
  return {};
48
46
  }
49
47
 
48
+ const DEFAULT_LOG_LEVEL = LogLevel.WARN;
49
+ const DEFAULT_LOG_LEVEL_NAME = Object.keys(LogLevel).find(key => LogLevel[key] === DEFAULT_LOG_LEVEL);
50
+
50
51
  class Logger {
51
52
  constructor() {
52
53
  // Default log level
53
- this.level = LogLevel.INFO
54
+ this.level = DEFAULT_LOG_LEVEL
54
55
  }
55
56
 
56
57
  // Setter for log level
@@ -60,7 +61,8 @@ class Logger {
60
61
  } else if (typeof level === 'number' && level >= -1 && level <= 4) {
61
62
  this.level = level
62
63
  } else {
63
- consoleWarn(`Invalid log level: ${level}. Using default INFO level.`)
64
+ this.level = DEFAULT_LOG_LEVEL
65
+ console.warn(`Invalid log level: ${level}. Using default ${DEFAULT_LOG_LEVEL_NAME} level.`)
64
66
  }
65
67
  return this
66
68
  }
@@ -85,37 +87,37 @@ class Logger {
85
87
 
86
88
  log(...args) {
87
89
  if (this.shouldLog(LogLevel.INFO)) {
88
- info(...this.formatMessage(args));
90
+ console.log(...this.formatMessage(args));
89
91
  }
90
92
  }
91
93
 
92
94
  error(...args) {
93
95
  if (this.shouldLog(LogLevel.ERROR)) {
94
- consoleError(...this.formatMessage(args));
96
+ console.error(...this.formatMessage(args));
95
97
  }
96
98
  }
97
99
 
98
100
  warn(...args) {
99
101
  if (this.shouldLog(LogLevel.WARN)) {
100
- consoleWarn(...this.formatMessage(args));
102
+ console.warn(...this.formatMessage(args));
101
103
  }
102
104
  }
103
105
 
104
106
  info(...args) {
105
107
  if (this.shouldLog(LogLevel.INFO)) {
106
- info(...this.formatMessage(args));
108
+ console.info(...this.formatMessage(args));
107
109
  }
108
110
  }
109
111
 
110
112
  debug(...args) {
111
113
  if (this.shouldLog(LogLevel.DEBUG)) {
112
- info(`[DEBUG]`, ...this.formatMessage(args));
114
+ console.debug(`[DEBUG]`, ...this.formatMessage(args));
113
115
  }
114
116
  }
115
117
 
116
118
  trace(...args) {
117
119
  if (this.shouldLog(LogLevel.TRACE)) {
118
- info(`[TRACE]`, ...this.formatMessage(args));
120
+ console.trace(`[TRACE]`, ...this.formatMessage(args));
119
121
  }
120
122
  }
121
123
 
@@ -1,7 +1,6 @@
1
1
  export * from './archive-plugin.js';
2
2
  export * from './default-board-actions-plugin.js';
3
3
  export * from './default-board-properties-plugin.js';
4
- export * from './default-plugins.js';
5
4
  export * from './epic-plugin.js';
6
5
  export * from './extension-plugin.js';
7
6
  export * from './persist-tags-plugin.js';
@@ -185,8 +185,10 @@ export class PluginManager extends Emitter {
185
185
 
186
186
  async createPlugin(pluginClass, path = undefined) {
187
187
  const name = pluginClass.pluginName
188
- if (!name || !this.isPlugin(pluginClass))
188
+ if (!name) {
189
189
  throw new Error(`${pluginClass.name} is not a plugin`)
190
+ }
191
+
190
192
  const pluginInstance = new pluginClass(this.project)
191
193
  const packageInfo = await this.getPackageInfo(path)
192
194
  let info = {
@@ -220,18 +222,6 @@ export class PluginManager extends Emitter {
220
222
  })
221
223
  }
222
224
 
223
- isPlugin(pluginClass) {
224
- // const pluginClassName = Plugin.name.toString()
225
- // return pluginClass.proname.toString() === pluginClassName
226
- const pluginClassPrototypeName = Object.getPrototypeOf(pluginClass.prototype).constructor.name
227
- const pluginClassName = Plugin.name.toString()
228
- logger.log('pluginClassPrototypeName', pluginClassPrototypeName)
229
- logger.log('pluginClassName', pluginClassName)
230
- return pluginClassPrototypeName === pluginClassName
231
-
232
- // return Object.getPrototypeOf(pluginClass.prototype) === Plugin.prototype
233
- }
234
-
235
225
  eachPlugin(cb) {
236
226
  Object.keys(this.pluginsMap).forEach((key) => {
237
227
  cb(this.getPlugin(key))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imdone-core",
3
- "version": "2.0.10",
3
+ "version": "2.0.12",
4
4
  "description": "imdone-core",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,7 +22,7 @@
22
22
  "coverage": "vitest --run --coverage",
23
23
  "link": "npm link ../imdone-api",
24
24
  "pre-commit": "npm run build:docs && npm run build:docs:index && npm run build:index && npm run build:types",
25
- "test": "vitest --run",
25
+ "test": "npm run coverage",
26
26
  "test-ci": "vitest --run",
27
27
  "serve": "npx docsify-cli serve",
28
28
  "prepare": "husky"
@@ -1,3 +1,14 @@
1
+ export function getCallerInfo(): {
2
+ functionName?: undefined;
3
+ file?: undefined;
4
+ line?: undefined;
5
+ column?: undefined;
6
+ } | {
7
+ functionName: string;
8
+ file: string;
9
+ line: number;
10
+ column: number;
11
+ };
1
12
  export const logger: Logger;
2
13
  declare class Logger {
3
14
  level: number;
@@ -1,7 +1,6 @@
1
1
  export * from "./archive-plugin.js";
2
2
  export * from "./default-board-actions-plugin.js";
3
3
  export * from "./default-board-properties-plugin.js";
4
- export * from "./default-plugins.js";
5
4
  export * from "./epic-plugin.js";
6
5
  export * from "./extension-plugin.js";
7
6
  export * from "./persist-tags-plugin.js";
@@ -22,7 +22,6 @@ export class PluginManager extends Emitter<[never]> {
22
22
  getPackageInfo(path: any): Promise<{} | undefined>;
23
23
  createPlugin(pluginClass: any, path?: undefined): Promise<any>;
24
24
  destroyPlugins(): void;
25
- isPlugin(pluginClass: any): boolean;
26
25
  eachPlugin(cb: any): void;
27
26
  eachPluginAsync(cb: any): Promise<void>;
28
27
  getPlugins(): any[];
package/vitest.config.js CHANGED
@@ -8,6 +8,8 @@ export default defineConfig({
8
8
  reporter: ["text"], // Ensure text output is included
9
9
  clean: false,
10
10
  reportOnFailure: true,
11
+ include: ['lib'], // Only include files from src/
12
+ exclude: ['_lib', 'lib/**/index.*']
11
13
  },
12
14
  },
13
15
  });
@@ -1,7 +0,0 @@
1
- export * as ArchivePlugin from './archive-plugin.js'
2
- export * as DefaultBoardActionsPlugin from './default-board-actions-plugin.js'
3
- export * as DefaultBoardPropertiesPlugin from './default-board-properties-plugin.js'
4
- export * as EpicPlugin from './epic-plugin.js'
5
- export * as PersistTagsPlugin from './persist-tags-plugin.js'
6
- export * as ExtensionPlugin from './extension-plugin.js'
7
-