forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUninstallAPI.js
More file actions
106 lines (94 loc) · 2.52 KB
/
UninstallAPI.js
File metadata and controls
106 lines (94 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const { removeSync } = require('fs-extra')
const semver = require('semver')
const extensionJson = require('./extension-json')
const getPackageJson = require('../helpers/get-package-json')
const BaseAPI = require('./BaseAPI')
// for backward compatibility
function getPackageName (packageName) {
return packageName === '@quasar/app'
? '@quasar/app-webpack'
: packageName
}
/**
* API for extension's /uninstall.js script
*/
module.exports = class UninstallAPI extends BaseAPI {
__hooks = {
exitLog: []
}
/**
* Get the internal persistent config of this extension.
* Returns empty object if it has none.
*
* @return {object} internal persistent config of this extension
*/
getPersistentConf () {
return extensionJson.getInternal(this.extId)
}
/**
* Check if an app package is installed. Can also
* check its version against specific semver condition.
*
* Example of semver condition:
* '1.x || >=2.5.0 || 5.0.0 - 7.2.3'
*
* @param {string} packageName
* @param {string} (optional) semverCondition
* @return {boolean} package is installed and meets optional semver condition
*/
hasPackage (packageName, semverCondition) {
const name = getPackageName(packageName)
const json = getPackageJson(name)
if (json === void 0) {
return false
}
return semverCondition !== void 0
? semver.satisfies(json.version, semverCondition)
: true
}
/**
* Check if another app extension is installed.
*
* @param {string} extId
* @return {boolean} has the extension installed.
*/
hasExtension (extId) {
return extensionJson.has(extId)
}
/**
* Get the version of an an app's package.
*
* @param {string} packageName
* @return {string|undefined} version of app's package
*/
getPackageVersion (packageName) {
const name = getPackageName(packageName)
const json = getPackageJson(name)
return json !== void 0
? json.version
: void 0
}
/**
* Remove a file or folder from devland which the
* extension has installed and is no longer needed.
*
* Be careful about it and do not delete the files
* that would break developer's app.
*
* The __path (file or folder) needs to be relative
* to project's root folder.
*
* @param {string} __path
*/
removePath (__path) {
removeSync(this.resolve.app(__path))
}
/**
* Add a message to be printed after App CLI finishes up install.
*
* @param {string} msg
*/
onExitLog (msg) {
this.__hooks.exitLog.push(msg)
}
}