adapt-cli 3.0.11 → 3.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.
Files changed (2) hide show
  1. package/lib/api.js +34 -0
  2. package/package.json +1 -1
package/lib/api.js CHANGED
@@ -64,6 +64,40 @@ class API {
64
64
  })
65
65
  }
66
66
 
67
+ /**
68
+ * Updates an existing installation of the framework
69
+ * @param {Object} options
70
+ * @param {string} [options.version=null] Specific version of the framework to install
71
+ * @param {string} [options.repository] URL to github repo
72
+ * @param {string} [options.cwd=process.cwd()] Directory to install into
73
+ * @return {Promise}
74
+ */
75
+ async updateFramework ({
76
+ version = null,
77
+ repository = ADAPT_FRAMEWORK,
78
+ cwd = process.cwd(),
79
+ logger
80
+ } = {}) {
81
+ // cache state of plugins, as these will be wiped
82
+ const plugins = (await new Project({ cwd }).getInstallTargets())
83
+ .map(p => p.isLocalSource ? p.sourcePath : `${p.name}@${p.requestedVersion}`)
84
+
85
+ await this.installFramework({ version, repository, cwd, logger })
86
+ // restore plugins
87
+ await this.installPlugins({ plugins, cwd, logger })
88
+ }
89
+
90
+ /**
91
+ * @param {Object} options
92
+ * @param {string} [options.cwd=process.cwd()] Directory to install into
93
+ * @returns {string}
94
+ */
95
+ getCurrentFrameworkVersion ({
96
+ cwd = process.cwd(),
97
+ } = {}) {
98
+ return new Project({ cwd }).version
99
+ }
100
+
67
101
  /**
68
102
  * @param {Object} options
69
103
  * @param {Object} [options.repository=ADAPT_FRAMEWORK] The github repository url
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adapt-cli",
3
- "version": "3.0.11",
3
+ "version": "3.1.0",
4
4
  "description": "Command line tools for Adapt",
5
5
  "main": "./lib/api.js",
6
6
  "type": "module",