imdone-core 1.54.10 → 2.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/.dependency-cruiser.cjs +412 -0
- package/.github/workflows/ci.yml +2 -2
- package/.imdoneignore +2 -1
- package/README.md +2 -2
- package/_index.md +7 -0
- package/build.js +57 -0
- package/esm-migration.md +446 -0
- package/lib/FileProjectContext.js +13 -0
- package/lib/ProjectContext.js +19 -18
- package/lib/adapters/date-time.js +3 -8
- package/lib/adapters/environment.js +3 -0
- package/lib/adapters/file-gateway.js +133 -106
- package/lib/adapters/git-download.js +36 -16
- package/lib/adapters/index.js +9 -0
- package/lib/adapters/logger.js +136 -0
- package/lib/adapters/markdown.js +31 -19
- package/lib/adapters/parsers/DateLanguageParser.js +11 -9
- package/lib/adapters/parsers/content-transformer.js +35 -30
- package/lib/adapters/parsers/file/LocalFileParserFactory.js +8 -9
- package/lib/adapters/parsers/file/ReadStreamCodeParser.js +8 -8
- package/lib/adapters/parsers/file/ReadStreamMarkdownParser.js +4 -4
- package/lib/adapters/parsers/file/ReadStreamTaskParser.js +5 -3
- package/lib/adapters/parsers/file/index.js +4 -0
- package/lib/adapters/parsers/function-parser.js +1 -5
- package/lib/adapters/parsers/index.js +5 -0
- package/lib/adapters/parsers/task/CardContentParser.js +23 -32
- package/lib/adapters/parsers/task/CheckStyleTaskParser.js +2 -2
- package/lib/adapters/parsers/task/CodeStyleTaskParser.js +2 -2
- package/lib/adapters/parsers/task/HashStyleTaskParser.js +3 -3
- package/lib/adapters/parsers/task/MarkdownStyleTaskParser.js +2 -2
- package/lib/adapters/parsers/task/TaskParser.js +1 -1
- package/lib/adapters/parsers/task/index.js +6 -0
- package/lib/adapters/storage/config.js +15 -20
- package/lib/adapters/storage/index.js +2 -0
- package/lib/adapters/storage/tags.js +11 -12
- package/lib/adapters/yaml.js +8 -5
- package/lib/card.js +25 -26
- package/lib/checksum.js +22 -0
- package/lib/cli.js +114 -0
- package/lib/config.js +106 -71
- package/lib/constants.js +21 -50
- package/lib/context/ApplicationContext.js +7 -4
- package/lib/context/index.js +1 -0
- package/lib/default-settings.js +3 -3
- package/lib/domain/entities/View.js +4 -11
- package/lib/domain/entities/index.js +1 -0
- package/lib/domain/index.js +2 -0
- package/lib/domain/usecases/GetViewsUsecase.js +6 -12
- package/lib/domain/usecases/SaveViewUsecase.js +8 -14
- package/lib/domain/usecases/index.js +2 -0
- package/lib/file.js +1158 -1162
- package/lib/get-tasks-to-modify.js +117 -0
- package/lib/index.js +23 -0
- package/lib/languages.js +4 -5
- package/lib/list.js +46 -95
- package/lib/migrate-config.js +5 -5
- package/lib/mixins/index.js +2 -0
- package/lib/mixins/repo-fs-store.js +224 -289
- package/lib/mixins/repo-watched-fs-store.js +158 -147
- package/lib/plugins/archive-plugin.js +10 -8
- package/lib/plugins/default-board-actions-plugin.js +2 -2
- package/lib/plugins/default-board-properties-plugin.js +7 -7
- package/lib/plugins/default-plugins.js +7 -0
- package/lib/plugins/epic-plugin.js +6 -5
- package/lib/plugins/extension-plugin.js +24 -17
- package/lib/plugins/index.js +9 -0
- package/lib/plugins/persist-tags-plugin.js +4 -3
- package/lib/plugins/plugin-manager.js +89 -52
- package/lib/plugins/plugin-registry.js +12 -16
- package/lib/project-factory.js +21 -24
- package/lib/project.js +97 -144
- package/lib/repository.js +1323 -1555
- package/lib/task.js +562 -580
- package/lib/tools.js +39 -113
- package/lib/usecases/actions.js +32 -0
- package/lib/usecases/get-project-tags.js +3 -12
- package/lib/usecases/get-tasks-in-file.js +4 -7
- package/lib/usecases/index.js +4 -0
- package/package.json +44 -66
- package/scripts/delete-markdown-indexes.js +87 -0
- package/scripts/generate-index.js +35 -0
- package/{index-markdown.js → scripts/index-markdown.js} +7 -7
- package/tsconfig.json +15 -0
- package/types/FileProjectContext.d.ts +4 -0
- package/types/ProjectContext.d.ts +9 -0
- package/types/adapters/date-time.d.ts +2 -0
- package/types/adapters/environment.d.ts +1 -0
- package/types/adapters/file-gateway.d.ts +51 -0
- package/types/adapters/git-download.d.ts +1 -0
- package/types/adapters/index.d.ts +9 -0
- package/types/adapters/logger.d.ts +24 -0
- package/types/adapters/markdown.d.ts +13 -0
- package/types/adapters/parsers/DateLanguageParser.d.ts +1 -0
- package/types/adapters/parsers/content-transformer.d.ts +10 -0
- package/types/adapters/parsers/file/LocalFileParserFactory.d.ts +5 -0
- package/types/adapters/parsers/file/ReadStreamCodeParser.d.ts +13 -0
- package/types/adapters/parsers/file/ReadStreamMarkdownParser.d.ts +7 -0
- package/types/adapters/parsers/file/ReadStreamTaskParser.d.ts +19 -0
- package/types/adapters/parsers/file/index.d.ts +4 -0
- package/types/adapters/parsers/function-parser.d.ts +1 -0
- package/types/adapters/parsers/index.d.ts +5 -0
- package/types/adapters/parsers/task/CardContentParser.d.ts +45 -0
- package/types/adapters/parsers/task/CheckStyleTaskParser.d.ts +12 -0
- package/types/adapters/parsers/task/CodeStyleTaskParser.d.ts +14 -0
- package/types/adapters/parsers/task/HashStyleTaskParser.d.ts +13 -0
- package/types/adapters/parsers/task/MarkdownStyleTaskParser.d.ts +14 -0
- package/types/adapters/parsers/task/TaskParser.d.ts +7 -0
- package/types/adapters/parsers/task/index.d.ts +6 -0
- package/types/adapters/storage/config.d.ts +6 -0
- package/types/adapters/storage/index.d.ts +2 -0
- package/types/adapters/storage/tags.d.ts +3 -0
- package/types/adapters/yaml.d.ts +2 -0
- package/types/card.d.ts +166 -0
- package/types/checksum.d.ts +8 -0
- package/types/config.d.ts +61 -0
- package/types/constants.d.ts +46 -0
- package/types/context/ApplicationContext.d.ts +24 -0
- package/types/context/index.d.ts +1 -0
- package/types/default-settings.d.ts +2 -0
- package/types/domain/entities/FileProjectContext.d.ts +5 -0
- package/types/domain/entities/View.d.ts +17 -0
- package/types/domain/entities/index.d.ts +1 -0
- package/types/domain/index.d.ts +2 -0
- package/types/domain/usecases/GetViewsUsecase.d.ts +4 -0
- package/types/domain/usecases/SaveViewUsecase.d.ts +8 -0
- package/types/domain/usecases/index.d.ts +2 -0
- package/types/file.d.ts +344 -0
- package/types/get-tasks-to-modify.d.ts +3 -0
- package/types/index.d.ts +23 -0
- package/types/languages.d.ts +649 -0
- package/types/list.d.ts +30 -0
- package/types/migrate-config.d.ts +1 -0
- package/types/mixins/index.d.ts +2 -0
- package/types/mixins/repo-fs-store.d.ts +2 -0
- package/types/mixins/repo-watched-fs-store.d.ts +2 -0
- package/types/plugins/archive-plugin.d.ts +8 -0
- package/types/plugins/default-board-actions-plugin.d.ts +9 -0
- package/types/plugins/default-board-properties-plugin.d.ts +16 -0
- package/types/plugins/default-plugins.d.ts +6 -0
- package/types/plugins/epic-plugin.d.ts +19 -0
- package/types/plugins/extension-plugin.d.ts +15 -0
- package/types/plugins/index.d.ts +9 -0
- package/types/plugins/persist-tags-plugin.d.ts +4 -0
- package/types/plugins/plugin-manager.d.ts +68 -0
- package/types/plugins/plugin-registry.d.ts +1 -0
- package/types/project-factory.d.ts +14 -0
- package/types/project.d.ts +158 -0
- package/types/repository.d.ts +996 -0
- package/types/task.d.ts +202 -0
- package/types/tools.d.ts +29 -0
- package/types/usecases/actions.d.ts +7 -0
- package/types/usecases/get-imdone-url.d.ts +1 -0
- package/types/usecases/get-project-tags.d.ts +1 -0
- package/types/usecases/get-tasks-in-file.d.ts +4 -0
- package/types/usecases/index.d.ts +4 -0
- package/vitest.config.js +13 -0
- package/cli.js +0 -74
- package/index.js +0 -1
- package/lib/adapters/readers/FileSystemProjectReader.js +0 -45
- package/lib/context/StreamingApplicationContext.js +0 -31
- package/lib/controlers/SaveViewController.js +0 -10
- package/lib/domain/entities/FileProjectContext.js +0 -10
- package/lib/domain/usecases/OpenProjectUsecase.js +0 -13
|
@@ -1,25 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import Emitter from 'events'
|
|
2
|
+
import Plugin from 'imdone-api'
|
|
3
|
+
import _path from 'path'
|
|
4
|
+
import { downloadPlugin } from '../adapters/git-download.js'
|
|
5
|
+
import rimraf from 'rimraf'
|
|
6
|
+
import chokidar from 'chokidar'
|
|
7
|
+
import debounce from 'lodash.debounce'
|
|
8
|
+
import { exists, mkdir, readdir } from '../adapters/file-gateway.js'
|
|
9
|
+
import { appContext } from '../context/ApplicationContext.js'
|
|
10
|
+
import { createRequire } from 'node:module';
|
|
11
|
+
|
|
12
|
+
import PersistTagsPlugin from './persist-tags-plugin.js'
|
|
13
|
+
import DefaultBoardPropertiesPlugin from './default-board-properties-plugin.js'
|
|
14
|
+
import DefaultBoardActionsPlugin from './default-board-actions-plugin.js'
|
|
15
|
+
import ArchivePlugin from './archive-plugin.js'
|
|
16
|
+
import EpicPlugin from './epic-plugin.js'
|
|
17
|
+
import ExtensionPlugin from './extension-plugin.js'
|
|
18
|
+
import { logger } from '../adapters/logger.js'
|
|
19
|
+
|
|
20
|
+
const require = createRequire(import.meta.url);
|
|
21
|
+
const url = new URL(import.meta.url)
|
|
22
|
+
const __dirname = _path.dirname(url.pathname)
|
|
23
|
+
|
|
24
|
+
export class PluginManager extends Emitter {
|
|
12
25
|
constructor(project) {
|
|
13
26
|
super()
|
|
14
27
|
this.project = project
|
|
15
28
|
this.defaultPlugins = [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
PersistTagsPlugin,
|
|
30
|
+
DefaultBoardPropertiesPlugin,
|
|
31
|
+
DefaultBoardActionsPlugin,
|
|
32
|
+
ArchivePlugin,
|
|
33
|
+
EpicPlugin,
|
|
34
|
+
ExtensionPlugin,
|
|
22
35
|
]
|
|
36
|
+
|
|
23
37
|
this.pluginsMap = {}
|
|
24
38
|
this.pluginPath = _path.join(project.path, '.imdone', 'plugins')
|
|
25
39
|
this.onDevChange = debounce(this.onDevChange.bind(this), 1000)
|
|
@@ -29,7 +43,7 @@ module.exports = class PluginManager extends Emitter {
|
|
|
29
43
|
if (this.project && this.project.config.devMode && !this.watcher) {
|
|
30
44
|
if (!(await exists(this.pluginPath)))
|
|
31
45
|
await mkdir(this.pluginPath)
|
|
32
|
-
this.watcher =
|
|
46
|
+
this.watcher = chokidar(this.pluginPath, {
|
|
33
47
|
ignored(path) {
|
|
34
48
|
return /node_modules/.test(path)
|
|
35
49
|
},
|
|
@@ -58,7 +72,7 @@ module.exports = class PluginManager extends Emitter {
|
|
|
58
72
|
await this.reloadPlugins()
|
|
59
73
|
this.emit('plugins-reloaded')
|
|
60
74
|
} catch {
|
|
61
|
-
|
|
75
|
+
logger.error('Error reloading plugins.', err)
|
|
62
76
|
throw err
|
|
63
77
|
}
|
|
64
78
|
}
|
|
@@ -71,7 +85,7 @@ module.exports = class PluginManager extends Emitter {
|
|
|
71
85
|
|
|
72
86
|
async uninstallPlugin(pluginName) {
|
|
73
87
|
return new Promise((resolve, reject) => {
|
|
74
|
-
|
|
88
|
+
logger.log('Preparing to uninstall plugin:', pluginName)
|
|
75
89
|
const pluginClassName = Object.keys(this.pluginsMap).find((key) => {
|
|
76
90
|
return this.getPlugin(key).info.name === pluginName
|
|
77
91
|
})
|
|
@@ -81,7 +95,7 @@ module.exports = class PluginManager extends Emitter {
|
|
|
81
95
|
const { info } = this.getPlugin(pluginClassName)
|
|
82
96
|
const { path } = info
|
|
83
97
|
// const pkg = { version, name }
|
|
84
|
-
|
|
98
|
+
logger.log('Uninstalling:', info)
|
|
85
99
|
|
|
86
100
|
rimraf(path, (err) => {
|
|
87
101
|
if (err) return reject(err)
|
|
@@ -96,15 +110,15 @@ module.exports = class PluginManager extends Emitter {
|
|
|
96
110
|
if (!(await exists(this.pluginPath)))
|
|
97
111
|
await mkdir(this.pluginPath)
|
|
98
112
|
const installPath = _path.join(this.pluginPath, name)
|
|
99
|
-
await
|
|
100
|
-
|
|
113
|
+
await downloadPlugin(version, installPath)
|
|
114
|
+
logger.log(`Done installing ${name}`)
|
|
101
115
|
await this.loadPlugin(installPath)
|
|
102
116
|
this.emit('plugin-installed', name)
|
|
103
117
|
}
|
|
104
118
|
|
|
105
119
|
async loadPlugins() {
|
|
106
|
-
for (const
|
|
107
|
-
await this.
|
|
120
|
+
for (const PluginClass of this.defaultPlugins) {
|
|
121
|
+
await this.createPlugin(PluginClass)
|
|
108
122
|
}
|
|
109
123
|
|
|
110
124
|
await this.loadInstalledPlugins()
|
|
@@ -143,40 +157,49 @@ module.exports = class PluginManager extends Emitter {
|
|
|
143
157
|
}
|
|
144
158
|
|
|
145
159
|
async loadPlugin(path) {
|
|
146
|
-
|
|
160
|
+
logger.log('Loading plugin: ', path)
|
|
161
|
+
const fullPath = path.endsWith('.js')
|
|
162
|
+
? _path.resolve(path)
|
|
163
|
+
: _path.join(_path.resolve(path), 'bundle.js')
|
|
164
|
+
|
|
147
165
|
try {
|
|
148
166
|
// eslint-disable-next-line
|
|
149
|
-
delete require.cache[require.resolve(
|
|
167
|
+
delete require.cache[require.resolve(fullPath)]
|
|
150
168
|
// eslint-disable-next-line
|
|
151
|
-
const pluginClass =
|
|
152
|
-
const pluginInstance = await this.createPlugin(pluginClass, path)
|
|
153
|
-
|
|
169
|
+
const pluginClass = await import(_path.resolve(path))
|
|
170
|
+
const pluginInstance = await this.createPlugin(pluginClass.default, path)
|
|
171
|
+
return pluginInstance
|
|
154
172
|
} catch (e) {
|
|
155
|
-
|
|
173
|
+
logger.error(`Error loading plugin at: ${path}`, e)
|
|
156
174
|
}
|
|
157
175
|
}
|
|
158
176
|
|
|
159
|
-
|
|
160
|
-
if (!
|
|
161
|
-
|
|
162
|
-
const name = pluginClass.name.toString()
|
|
163
|
-
const pluginInstance = new pluginClass(this.project)
|
|
164
|
-
let info = {}
|
|
177
|
+
getPackageInfo(path) {
|
|
178
|
+
if (!path) return {}
|
|
179
|
+
let info = { path }
|
|
165
180
|
try {
|
|
166
|
-
info = require(`${path}/package.json`)
|
|
181
|
+
info = {...info, ...require(`${path}/package.json`) }
|
|
167
182
|
delete info.dependencies
|
|
168
183
|
delete info.devDependencies
|
|
169
184
|
delete info.scripts
|
|
170
185
|
delete info.main
|
|
171
186
|
} catch (e) {
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
|
|
187
|
+
logger.info('No info on plugin:', path)
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async createPlugin(pluginClass, path = undefined) {
|
|
192
|
+
if (!this.isPlugin(pluginClass))
|
|
193
|
+
throw new Error(`${pluginClass.name} is not a plugin`)
|
|
194
|
+
const name = pluginClass.name.toString()
|
|
195
|
+
const pluginInstance = new pluginClass(this.project)
|
|
196
|
+
let info = {
|
|
197
|
+
name,
|
|
198
|
+
...this.getPackageInfo(path),
|
|
176
199
|
}
|
|
177
200
|
|
|
178
201
|
pluginInstance.getSettings = () => {
|
|
179
|
-
return this.getPluginSettings(
|
|
202
|
+
return this.getPluginSettings(name)
|
|
180
203
|
}
|
|
181
204
|
|
|
182
205
|
this.pluginsMap[name] = {
|
|
@@ -185,6 +208,8 @@ module.exports = class PluginManager extends Emitter {
|
|
|
185
208
|
info,
|
|
186
209
|
}
|
|
187
210
|
|
|
211
|
+
if (pluginInstance.init) await pluginInstance.init()
|
|
212
|
+
|
|
188
213
|
return pluginInstance
|
|
189
214
|
}
|
|
190
215
|
|
|
@@ -200,7 +225,15 @@ module.exports = class PluginManager extends Emitter {
|
|
|
200
225
|
}
|
|
201
226
|
|
|
202
227
|
isPlugin(pluginClass) {
|
|
203
|
-
|
|
228
|
+
// const pluginClassName = Plugin.name.toString()
|
|
229
|
+
// return pluginClass.proname.toString() === pluginClassName
|
|
230
|
+
const pluginClassPrototypeName = Object.getPrototypeOf(pluginClass.prototype).constructor.name
|
|
231
|
+
const pluginClassName = Plugin.name.toString()
|
|
232
|
+
logger.log('pluginClassPrototypeName', pluginClassPrototypeName)
|
|
233
|
+
logger.log('pluginClassName', pluginClassName)
|
|
234
|
+
return pluginClassPrototypeName === pluginClassName
|
|
235
|
+
|
|
236
|
+
// return Object.getPrototypeOf(pluginClass.prototype) === Plugin.prototype
|
|
204
237
|
}
|
|
205
238
|
|
|
206
239
|
eachPlugin(cb) {
|
|
@@ -227,6 +260,10 @@ module.exports = class PluginManager extends Emitter {
|
|
|
227
260
|
})
|
|
228
261
|
}
|
|
229
262
|
|
|
263
|
+
disablePlugin(name) {
|
|
264
|
+
delete this.pluginsMap[name]
|
|
265
|
+
}
|
|
266
|
+
|
|
230
267
|
getPluginName(pluginInstance) {
|
|
231
268
|
return Object.keys(this.pluginsMap).find(
|
|
232
269
|
(pluginName) =>
|
|
@@ -249,7 +286,7 @@ module.exports = class PluginManager extends Emitter {
|
|
|
249
286
|
}
|
|
250
287
|
|
|
251
288
|
pluginError(method, pluginInstance, error) {
|
|
252
|
-
|
|
289
|
+
logger.warn(
|
|
253
290
|
`Plugin: ${this.getPluginName(
|
|
254
291
|
pluginInstance
|
|
255
292
|
)} threw an error on ${method}: `,
|
|
@@ -261,13 +298,13 @@ module.exports = class PluginManager extends Emitter {
|
|
|
261
298
|
if (!lists || lists.length == 0) return
|
|
262
299
|
await this.eachPluginAsync(async ({ pluginInstance }) => {
|
|
263
300
|
// const timeLabel = `${this.getPluginName(pluginInstance)} onBoardUpdate time`
|
|
264
|
-
//
|
|
301
|
+
// logger.time(timeLabel)
|
|
265
302
|
try {
|
|
266
303
|
await pluginInstance.onBoardUpdate(lists)
|
|
267
304
|
} catch (e) {
|
|
268
305
|
this.pluginError('onBoardUpdate', pluginInstance, e)
|
|
269
306
|
}
|
|
270
|
-
//
|
|
307
|
+
// logger.timeEnd(timeLabel)
|
|
271
308
|
})
|
|
272
309
|
return lists
|
|
273
310
|
}
|
|
@@ -340,10 +377,7 @@ module.exports = class PluginManager extends Emitter {
|
|
|
340
377
|
return cardProps
|
|
341
378
|
}
|
|
342
379
|
|
|
343
|
-
|
|
344
|
-
// <!--
|
|
345
|
-
// order:-10
|
|
346
|
-
// -->
|
|
380
|
+
|
|
347
381
|
async getBoardProperties() {
|
|
348
382
|
let boardProps = {}
|
|
349
383
|
await this.eachPluginAsync(async ({ pluginInstance }) => {
|
|
@@ -409,13 +443,16 @@ module.exports = class PluginManager extends Emitter {
|
|
|
409
443
|
}
|
|
410
444
|
|
|
411
445
|
async performBoardAction(action, task) {
|
|
446
|
+
const title = action.title || action.name
|
|
412
447
|
const plugin = this.getPluginInstance(action.plugin)
|
|
413
448
|
try {
|
|
414
449
|
return action.index
|
|
415
450
|
? await plugin.getBoardActions()[action.index].action(task)
|
|
416
|
-
: await plugin.getBoardActions().find(a => a.title ===
|
|
451
|
+
: await plugin.getBoardActions().find(a => a.title === title).action(task)
|
|
417
452
|
} catch (e) {
|
|
453
|
+
|
|
418
454
|
this.pluginError('getBoardActions', plugin, e)
|
|
455
|
+
throw new Error(`Error performing action ${title} on plugin ${plugin.name}: ${e.message}`)
|
|
419
456
|
}
|
|
420
457
|
}
|
|
421
458
|
}
|
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
import https from 'https'
|
|
2
|
+
import {
|
|
2
3
|
renderMarkdown,
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
|
|
7
|
-
getAvailablePlugins: async function () {
|
|
8
|
-
const response = await fetch('https://raw.githubusercontent.com/imdone/imdone-plugins/main/index.json')
|
|
9
|
-
const plugins = response.body
|
|
10
|
-
for (const plugin of plugins) {
|
|
11
|
-
plugin.content = renderMarkdown(await getReadmeContent(plugin))
|
|
12
|
-
}
|
|
13
|
-
return plugins
|
|
14
|
-
},
|
|
4
|
+
} from '../adapters/markdown.js'
|
|
15
5
|
|
|
6
|
+
export async function getAvailablePlugins() {
|
|
7
|
+
const response = await fetch('https://raw.githubusercontent.com/imdone/imdone-plugins/main/index.json')
|
|
8
|
+
const plugins = response.body
|
|
9
|
+
for (const plugin of plugins) {
|
|
10
|
+
plugin.content = renderMarkdown(await getReadmeContent(plugin))
|
|
11
|
+
}
|
|
12
|
+
return plugins
|
|
16
13
|
}
|
|
17
14
|
|
|
18
15
|
async function getReadmeContent({version}) {
|
|
19
16
|
const response = await fetch(`https://api.github.com/repos/${version}/readme`)
|
|
20
|
-
const { content } = response
|
|
17
|
+
const { content } = response?.body
|
|
18
|
+
if (!content) return ''
|
|
21
19
|
const buffer = Buffer.from(content, 'base64');
|
|
22
20
|
return buffer.toString('utf-8');
|
|
23
21
|
}
|
|
24
22
|
|
|
25
|
-
const https = require('https')
|
|
26
|
-
|
|
27
23
|
async function fetch(url, opts = { method: 'GET', headers: {} }) {
|
|
28
24
|
const { method, headers, body, debug = () => { } } = opts
|
|
29
25
|
if (body) headers['Content-Length'] = body.length
|
package/lib/project-factory.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { Repository } from './repository.js'
|
|
2
|
+
import { watchedFileSystemStoreMixin } from './mixins/repo-watched-fs-store.js'
|
|
3
|
+
import { fileSystemStoreMixin } from './mixins/repo-fs-store.js'
|
|
4
|
+
import { ProjectContext } from './ProjectContext.js'
|
|
5
|
+
import { WorkerProject } from './project.js'
|
|
6
|
+
import { appContext as context } from './context/ApplicationContext.js'
|
|
7
|
+
import _path from 'node:path'
|
|
7
8
|
|
|
8
|
-
function createFileSystemProject({
|
|
9
|
+
export function createFileSystemProject({
|
|
9
10
|
path,
|
|
10
11
|
config,
|
|
11
|
-
repo =
|
|
12
|
+
repo = fileSystemStoreMixin(new Repository(_path.resolve(path), config)),
|
|
12
13
|
loadInstalledPlugins,
|
|
13
14
|
loadPluginsNotInstalled
|
|
14
15
|
}) {
|
|
15
16
|
context().repo = repo
|
|
16
17
|
context().projectContext = new ProjectContext(repo)
|
|
17
|
-
context().project = new
|
|
18
|
+
context().project = new WorkerProject(repo)
|
|
18
19
|
if (loadInstalledPlugins) {
|
|
19
20
|
context().project.pluginManager.loadInstalledPlugins = loadInstalledPlugins
|
|
20
21
|
}
|
|
@@ -24,22 +25,18 @@ function createFileSystemProject({
|
|
|
24
25
|
return context().project
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
export function createWatchedFileSystemProject({
|
|
29
|
+
path,
|
|
30
|
+
config,
|
|
31
|
+
repo = watchedFileSystemStoreMixin(new Repository(_path.resolve(path), config)),
|
|
32
|
+
loadInstalledPlugins,
|
|
33
|
+
loadPluginsNotInstalled
|
|
34
|
+
}) {
|
|
35
|
+
return createFileSystemProject({
|
|
29
36
|
path,
|
|
30
37
|
config,
|
|
31
|
-
repo
|
|
38
|
+
repo,
|
|
32
39
|
loadInstalledPlugins,
|
|
33
|
-
loadPluginsNotInstalled
|
|
34
|
-
})
|
|
35
|
-
return createFileSystemProject({
|
|
36
|
-
path,
|
|
37
|
-
config,
|
|
38
|
-
repo,
|
|
39
|
-
loadInstalledPlugins,
|
|
40
|
-
loadPluginsNotInstalled
|
|
41
|
-
})
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
createFileSystemProject
|
|
40
|
+
loadPluginsNotInstalled
|
|
41
|
+
})
|
|
45
42
|
}
|