particle-commands 0.5.2 → 1.0.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/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
4
4
  and this project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ### 1.0.0 - 2024-03-13
7
+ - Remove yeoman and use own template engine with particle-library-manager new version
8
+
9
+ ### 0.5.3 - 2023-10-18
10
+ - Fix template
11
+
6
12
  ### 0.5.2 - 2023-10-17
7
13
  - Fix asset ota key in project properties file
8
14
 
@@ -3,16 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.CommandSite = exports.AbstractStatefulCommand = exports.Command = undefined;
7
6
 
8
7
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
9
8
 
10
- var _when = require('when');
11
-
12
- var _when2 = _interopRequireDefault(_when);
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
9
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
10
 
18
11
  /**
@@ -45,18 +38,15 @@ var CommandSite = function () {
45
38
  value: function end(state, cmd) {}
46
39
  }, {
47
40
  key: 'run',
48
- value: function run(cmd) {
49
- var _this = this;
50
-
41
+ value: async function run(cmd) {
51
42
  var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
52
43
 
53
- return (0, _when2.default)().then(function () {
54
- return _this.begin(state, _this);
55
- }).then(function () {
56
- return cmd.run(state, _this);
57
- }).finally(function () {
58
- return _this.end(state, _this);
59
- });
44
+ try {
45
+ await this.begin(state, this);
46
+ await cmd.run(state, this);
47
+ } finally {
48
+ await this.end(state, this);
49
+ }
60
50
  }
61
51
  }]);
62
52
 
@@ -7,18 +7,12 @@ exports.LibraryAddCommand = exports.LibraryAddCommandSite = undefined;
7
7
 
8
8
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
9
9
 
10
- var _pipeline = require('when/pipeline');
11
-
12
- var _pipeline2 = _interopRequireDefault(_pipeline);
13
-
14
10
  var _api = require('./api');
15
11
 
16
12
  var _command = require('./command');
17
13
 
18
14
  var _library = require('./library');
19
15
 
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
16
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
23
17
 
24
18
  function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
@@ -80,8 +74,6 @@ var LibraryAddCommand = exports.LibraryAddCommand = function () {
80
74
  * @returns {Promise} Library add process
81
75
  */
82
76
  value: function run(state, site) {
83
- var _this2 = this;
84
-
85
77
  this.site = site;
86
78
 
87
79
  var lib = site.libraryIdent();
@@ -89,25 +81,24 @@ var LibraryAddCommand = exports.LibraryAddCommand = function () {
89
81
  lib.version = 'latest';
90
82
  }
91
83
  var directory = this.site.projectDir();
92
- return (0, _pipeline2.default)([function () {
93
- return _this2.ensureProjectExists(directory);
94
- }, function () {
95
- return _this2.loadProject();
96
- }, function () {
97
- return _this2.fetchLibrary(lib.name, lib.version);
98
- }, function (library) {
99
- return _this2.addLibraryToProject(library);
100
- }, function () {
101
- return _this2.saveProject();
102
- }]);
84
+ return this._loadLibrary(directory, lib);
85
+ }
86
+ }, {
87
+ key: '_loadLibrary',
88
+ value: async function _loadLibrary(directory, lib) {
89
+ await this.ensureProjectExists(directory);
90
+ await this.loadProject();
91
+ var library = await this.fetchLibrary(lib.name, lib.version);
92
+ await this.addLibraryToProject(library);
93
+ await this.saveProject();
103
94
  }
104
95
  }, {
105
96
  key: 'ensureProjectExists',
106
97
  value: function ensureProjectExists(directory) {
107
- var _this3 = this;
98
+ var _this2 = this;
108
99
 
109
100
  return (0, _library.findProject)(directory, true).then(function (project) {
110
- _this3.properties = project;
101
+ _this2.properties = project;
111
102
  return project;
112
103
  });
113
104
  }
@@ -125,12 +116,12 @@ var LibraryAddCommand = exports.LibraryAddCommand = function () {
125
116
  }, {
126
117
  key: 'fetchLibrary',
127
118
  value: function fetchLibrary(name, version) {
128
- var _this4 = this;
119
+ var _this3 = this;
129
120
 
130
121
  return Promise.resolve(this.site.apiClient()).then(function (apiClient) {
131
- return Promise.resolve(_this4.site.fetchingLibrary(apiClient.library(name, { version: version }), name, version));
122
+ return Promise.resolve(_this3.site.fetchingLibrary(apiClient.library(name, { version: version }), name, version));
132
123
  }).catch(function (err) {
133
- throw _this4.apiError(err);
124
+ throw _this3.apiError(err);
134
125
  });
135
126
  }
136
127
  }, {
@@ -140,14 +131,9 @@ var LibraryAddCommand = exports.LibraryAddCommand = function () {
140
131
  }
141
132
  }, {
142
133
  key: 'addLibraryToProject',
143
- value: function addLibraryToProject(library) {
144
- var _this5 = this;
145
-
146
- return (0, _pipeline2.default)([function () {
147
- return _this5.site.addedLibrary(library.name, library.version);
148
- }, function () {
149
- return _this5.properties.addDependency(library.name, library.version);
150
- }]);
134
+ value: async function addLibraryToProject(library) {
135
+ await this.site.addedLibrary(library.name, library.version);
136
+ await this.properties.addDependency(library.name, library.version);
151
137
  }
152
138
  }, {
153
139
  key: 'saveProject',
@@ -17,13 +17,10 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
17
17
 
18
18
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
19
19
 
20
- var promisify = require('es6-promisify');
21
-
22
20
  /**
23
21
  * Specification and base implementation for the site instance expected by
24
22
  * the LibraryInitCommand.
25
23
  */
26
-
27
24
  var LibraryInitCommandSite = exports.LibraryInitCommandSite = function (_CommandSite) {
28
25
  _inherits(LibraryInitCommandSite, _CommandSite);
29
26
 
@@ -34,16 +31,6 @@ var LibraryInitCommandSite = exports.LibraryInitCommandSite = function (_Command
34
31
  }
35
32
 
36
33
  _createClass(LibraryInitCommandSite, [{
37
- key: 'yeomanAdapter',
38
- value: function yeomanAdapter() {
39
- throw new Error('not implemented');
40
- }
41
- }, {
42
- key: 'yeomanEnvironment',
43
- value: function yeomanEnvironment() {
44
- throw new Error('not implemented');
45
- }
46
- }, {
47
34
  key: 'options',
48
35
  value: function options() {
49
36
  return {};
@@ -53,6 +40,16 @@ var LibraryInitCommandSite = exports.LibraryInitCommandSite = function (_Command
53
40
  value: function args() {
54
41
  return [];
55
42
  }
43
+ }, {
44
+ key: 'prompter',
45
+ value: function prompter() {
46
+ throw new Error('not implemented');
47
+ }
48
+ }, {
49
+ key: 'outputStreamer',
50
+ value: function outputStreamer() {
51
+ throw new Error('not implemented');
52
+ }
56
53
  }]);
57
54
 
58
55
  return LibraryInitCommandSite;
@@ -73,10 +70,8 @@ var LibraryInitCommand = exports.LibraryInitCommand = function (_Command) {
73
70
  }
74
71
 
75
72
  _createClass(LibraryInitCommand, [{
76
- key: 'generatorClass',
77
- value: function generatorClass() {
78
- return (0, _particleLibraryManager.buildLibraryInitGeneratorClass)();
79
- }
73
+ key: 'run',
74
+
80
75
 
81
76
  /**
82
77
  *
@@ -84,29 +79,11 @@ var LibraryInitCommand = exports.LibraryInitCommand = function (_Command) {
84
79
  * @param {LibraryInitCommandSite} site external services.
85
80
  * @returns {Promise} To run the library initialization command.
86
81
  */
87
-
88
- }, {
89
- key: 'run',
90
82
  value: function run(state, site) {
91
- var yeoman = site.yeomanEnvironment();
92
- var args = site.args();
93
83
  var opts = site.options();
94
- var env = yeoman.createEnv(args, opts, site.yeomanAdapter());
95
- env.registerStub(this.generatorClass(), 'library:init');
96
- var run = promisify(function () {
97
- return env.run.apply(env, arguments);
98
- });
99
- return run(['library:init'], opts);
100
-
101
- // we ideally want the instance so that we can hook the 'end' event
102
- // yeoman-evironment doesn't provide the instance with the registration method above
103
- // so we dive below the covers and do it ourselves...
104
- // const generator = env.instantiate(LibraryInitGenerator, opts);
105
- // return new Promise((fulfill, reject) => {
106
- // generator.on('end', fulfill);
107
- // generator.on('error', reject);
108
- // generator.run();
109
- // });
84
+
85
+ var generator = new _particleLibraryManager.LibraryInitGenerator({ prompt: site.prompter(), stdout: site.outputStreamer() });
86
+ return generator.run({ options: opts });
110
87
  }
111
88
  }]);
112
89
 
@@ -17,14 +17,6 @@ var _path = require('path');
17
17
 
18
18
  var _path2 = _interopRequireDefault(_path);
19
19
 
20
- var _when = require('when');
21
-
22
- var _when2 = _interopRequireDefault(_when);
23
-
24
- var _pipeline = require('when/pipeline');
25
-
26
- var _pipeline2 = _interopRequireDefault(_pipeline);
27
-
28
20
  var _library_install = require('./library_install');
29
21
 
30
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -105,25 +97,29 @@ var AbstractLibraryMigrateCommand = function (_Command) {
105
97
  * - result: result of running `processLibrary()` if no errors were produced.
106
98
  * - err: any error that was produced.
107
99
  */
108
- value: function run(state, site) {
100
+ value: async function run(state, site) {
109
101
  var _this3 = this;
110
102
 
111
- var libsPromise = Promise.resolve(site.getLibraries());
112
- return _when2.default.map(libsPromise, function (libdir) {
113
- return Promise.resolve(site.notifyStart(libdir)).then(function () {
114
- var dir = _path2.default.resolve(libdir);
115
- var repo = new _particleLibraryManager.FileSystemLibraryRepository(dir, _particleLibraryManager.FileSystemNamingStrategy.DIRECT);
116
- return _this3.processLibrary(repo, '', state, site, libdir).then(function (_ref) {
117
- var _ref2 = _slicedToArray(_ref, 2),
118
- res = _ref2[0],
119
- err = _ref2[1];
120
-
121
- return Promise.resolve(site.notifyEnd(libdir, res, err)).then(function () {
122
- return { libdir: libdir, res: res, err: err };
123
- });
124
- });
125
- });
103
+ var libraries = await site.getLibraries();
104
+ var promises = libraries.map(function (libdir) {
105
+ return _this3._executeLibrary(libdir, state, site);
126
106
  });
107
+ return Promise.all(promises);
108
+ }
109
+ }, {
110
+ key: '_executeLibrary',
111
+ value: async function _executeLibrary(libdir, state, site) {
112
+ await site.notifyStart(libdir);
113
+ var dir = _path2.default.resolve(libdir);
114
+ var repo = new _particleLibraryManager.FileSystemLibraryRepository(dir, _particleLibraryManager.FileSystemNamingStrategy.DIRECT);
115
+
116
+ var _ref = await this.processLibrary(repo, '', state, site, libdir),
117
+ _ref2 = _slicedToArray(_ref, 2),
118
+ res = _ref2[0],
119
+ err = _ref2[1];
120
+
121
+ await site.notifyEnd(libdir, res, err);
122
+ return { libdir: libdir, res: res, err: err };
127
123
  }
128
124
 
129
125
  /**
@@ -180,22 +176,21 @@ var LibraryMigrateCommand = exports.LibraryMigrateCommand = function (_AbstractL
180
176
 
181
177
  _createClass(LibraryMigrateCommand, [{
182
178
  key: 'processLibrary',
183
- value: function processLibrary(repo, libname, state, site, libdir) {
184
- return resultError((0, _pipeline2.default)([function () {
185
- return repo.getLibraryLayout(libname);
186
- }, function (layout) {
187
- if (layout === 2) {
188
- return false;
189
- } else {
190
- return repo.setLibraryLayout(libname, 2).then(function () {
191
- if (site.isAdaptersRequired()) {
192
- return (0, _library_install.buildAdapters)(libdir, libname);
193
- }
194
- }).then(function () {
195
- return true;
196
- });
197
- }
198
- }]));
179
+ value: async function processLibrary(repo, libname, state, site, libdir) {
180
+ return resultError(this._processLibrary(repo, libname, state, site, libdir));
181
+ }
182
+ }, {
183
+ key: '_processLibrary',
184
+ value: async function _processLibrary(repo, libname, state, site, libdir) {
185
+ var layout = await repo.getLibraryLayout(libname);
186
+ if (layout === 2) {
187
+ return false;
188
+ }
189
+ await repo.setLibraryLayout(libname, 2);
190
+ if (site.isAdaptersRequired()) {
191
+ await (0, _library_install.buildAdapters)(libdir, libname);
192
+ }
193
+ return true;
199
194
  }
200
195
  }]);
201
196
 
@@ -29,7 +29,7 @@ void loop() {
29
29
  // The core of your code will likely live here.
30
30
 
31
31
  // Example: Publish event to cloud every 10 seconds. Uncomment the next 3 lines to try it!
32
- // Logging.info("Sending Hello World to the cloud!");
32
+ // Log.info("Sending Hello World to the cloud!");
33
33
  // Particle.publish("Hello world!");
34
34
  // delay( 10 * 1000 ); // milliseconds and blocking - see docs for more info!
35
35
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "particle-commands",
3
3
  "description": "Library of UX-neutral commands that provide key functionality for developer tools",
4
- "version": "0.5.2",
4
+ "version": "1.0.0",
5
5
  "author": "Matthew McGowan",
6
6
  "bugs": {
7
7
  "url": "https://github.com/particle-iot/particle-commands/issues"
@@ -17,13 +17,10 @@
17
17
  "es6-promisify": "^4.1.0",
18
18
  "mkdirp": "^0.5.1",
19
19
  "particle-api-js": "^6.5.0",
20
- "particle-library-manager": "^0.1.13",
20
+ "particle-library-manager": "^1.0.0",
21
21
  "semver": "^5.1.0",
22
22
  "underscore": "^1.8.3",
23
- "when": "^3.7.2",
24
- "winreg": "^1.2.2",
25
- "yeoman-environment": "^1.6.6",
26
- "yeoman-generator": "^1.1.1"
23
+ "winreg": "^1.2.2"
27
24
  },
28
25
  "devDependencies": {
29
26
  "babel-cli": "^6.10.1",
@@ -1,5 +1,3 @@
1
- import when from 'when';
2
-
3
1
  /**
4
2
  * Describes the interface expected of objects passed as the command site to a command.
5
3
  */
@@ -22,11 +20,13 @@ class CommandSite {
22
20
  end(state, cmd) {}
23
21
 
24
22
 
25
- run(cmd, state = {}) {
26
- return when()
27
- .then(() => this.begin(state, this))
28
- .then(() => cmd.run(state, this))
29
- .finally(() => this.end(state, this));
23
+ async run(cmd, state = {}) {
24
+ try {
25
+ await this.begin(state, this);
26
+ await cmd.run(state, this);
27
+ } finally {
28
+ await this.end(state, this);
29
+ }
30
30
  }
31
31
  }
32
32
 
@@ -1,5 +1,3 @@
1
-
2
- import pipeline from 'when/pipeline';
3
1
  import { convertApiError } from './api';
4
2
  import { CommandSite } from './command';
5
3
  import { findProject } from './library';
@@ -45,13 +43,15 @@ export class LibraryAddCommand {
45
43
  lib.version = 'latest';
46
44
  }
47
45
  const directory = this.site.projectDir();
48
- return pipeline([
49
- () => this.ensureProjectExists(directory),
50
- () => this.loadProject(),
51
- () => this.fetchLibrary(lib.name, lib.version),
52
- (library) => this.addLibraryToProject(library),
53
- () => this.saveProject()
54
- ]);
46
+ return this._loadLibrary(directory, lib);
47
+ }
48
+
49
+ async _loadLibrary(directory, lib) {
50
+ await this.ensureProjectExists(directory);
51
+ await this.loadProject();
52
+ const library = await this.fetchLibrary(lib.name, lib.version);
53
+ await this.addLibraryToProject(library);
54
+ await this.saveProject();
55
55
  }
56
56
 
57
57
  ensureProjectExists(directory) {
@@ -86,11 +86,9 @@ export class LibraryAddCommand {
86
86
  return convertApiError(err);
87
87
  }
88
88
 
89
- addLibraryToProject(library) {
90
- return pipeline([
91
- () => this.site.addedLibrary(library.name, library.version),
92
- () => this.properties.addDependency(library.name, library.version)
93
- ]);
89
+ async addLibraryToProject(library) {
90
+ await this.site.addedLibrary(library.name, library.version);
91
+ await this.properties.addDependency(library.name, library.version);
94
92
  }
95
93
 
96
94
  saveProject() {
@@ -1,7 +1,5 @@
1
1
  import { Command, CommandSite } from './command';
2
- import { buildLibraryInitGeneratorClass } from 'particle-library-manager';
3
-
4
- const promisify = require('es6-promisify');
2
+ import { LibraryInitGenerator } from 'particle-library-manager';
5
3
 
6
4
  /**
7
5
  * Specification and base implementation for the site instance expected by
@@ -13,14 +11,6 @@ export class LibraryInitCommandSite extends CommandSite {
13
11
  super();
14
12
  }
15
13
 
16
- yeomanAdapter() {
17
- throw new Error('not implemented');
18
- }
19
-
20
- yeomanEnvironment() {
21
- throw new Error('not implemented');
22
- }
23
-
24
14
  options() {
25
15
  return {};
26
16
  }
@@ -29,6 +19,14 @@ export class LibraryInitCommandSite extends CommandSite {
29
19
  return [];
30
20
  }
31
21
 
22
+ prompter() {
23
+ throw new Error('not implemented');
24
+ }
25
+
26
+ outputStreamer() {
27
+ throw new Error('not implemented');
28
+ }
29
+
32
30
  }
33
31
 
34
32
  /**
@@ -36,10 +34,6 @@ export class LibraryInitCommandSite extends CommandSite {
36
34
  */
37
35
  export class LibraryInitCommand extends Command {
38
36
 
39
- generatorClass() {
40
- return buildLibraryInitGeneratorClass();
41
- }
42
-
43
37
  /**
44
38
  *
45
39
  * @param {object} state The current conversation state.
@@ -47,23 +41,10 @@ export class LibraryInitCommand extends Command {
47
41
  * @returns {Promise} To run the library initialization command.
48
42
  */
49
43
  run(state, site) {
50
- const yeoman = site.yeomanEnvironment();
51
- const args = site.args();
52
44
  const opts = site.options();
53
- const env = yeoman.createEnv(args, opts, site.yeomanAdapter());
54
- env.registerStub(this.generatorClass(), 'library:init');
55
- const run = promisify((...args) => env.run(...args));
56
- return run(['library:init'], opts);
57
45
 
58
- // we ideally want the instance so that we can hook the 'end' event
59
- // yeoman-evironment doesn't provide the instance with the registration method above
60
- // so we dive below the covers and do it ourselves...
61
- // const generator = env.instantiate(LibraryInitGenerator, opts);
62
- // return new Promise((fulfill, reject) => {
63
- // generator.on('end', fulfill);
64
- // generator.on('error', reject);
65
- // generator.run();
66
- // });
46
+ const generator = new LibraryInitGenerator({ prompt: site.prompter(), stdout: site.outputStreamer() });
47
+ return generator.run({ options: opts });
67
48
  }
68
49
  }
69
50
 
@@ -1,9 +1,6 @@
1
1
  import { Command, CommandSite } from './command';
2
-
3
2
  import { FileSystemLibraryRepository, FileSystemNamingStrategy } from 'particle-library-manager';
4
3
  import path from 'path';
5
- import when from 'when';
6
- import pipeline from 'when/pipeline';
7
4
  import { buildAdapters } from './library_install';
8
5
 
9
6
  export class LibraryMigrateCommandSite extends CommandSite {
@@ -46,22 +43,19 @@ class AbstractLibraryMigrateCommand extends Command {
46
43
  * - result: result of running `processLibrary()` if no errors were produced.
47
44
  * - err: any error that was produced.
48
45
  */
49
- run(state, site) {
50
- const libsPromise = Promise.resolve(site.getLibraries());
51
- return when.map(libsPromise, libdir => {
52
- return Promise.resolve(site.notifyStart(libdir))
53
- .then(() => {
54
- const dir = path.resolve(libdir);
55
- const repo = new FileSystemLibraryRepository(dir, FileSystemNamingStrategy.DIRECT);
56
- return this.processLibrary(repo, '', state, site, libdir)
57
- .then(([res, err]) => {
58
- return Promise.resolve(site.notifyEnd(libdir, res, err))
59
- .then(() => {
60
- return { libdir, res, err };
61
- });
62
- });
63
- });
64
- });
46
+ async run(state, site) {
47
+ const libraries = await site.getLibraries();
48
+ const promises = libraries.map(libdir => this._executeLibrary(libdir, state, site));
49
+ return Promise.all(promises);
50
+ }
51
+
52
+ async _executeLibrary(libdir, state, site){
53
+ await site.notifyStart(libdir);
54
+ const dir = path.resolve(libdir);
55
+ const repo = new FileSystemLibraryRepository(dir, FileSystemNamingStrategy.DIRECT);
56
+ const [res, err] = await this.processLibrary(repo, '', state, site, libdir);
57
+ await site.notifyEnd(libdir, res, err);
58
+ return { libdir, res, err };
65
59
  }
66
60
 
67
61
  /**
@@ -89,22 +83,19 @@ export class LibraryMigrateTestCommand extends AbstractLibraryMigrateCommand {
89
83
 
90
84
  export class LibraryMigrateCommand extends AbstractLibraryMigrateCommand {
91
85
 
92
- processLibrary(repo, libname, state, site, libdir) {
93
- return resultError(pipeline([
94
- () => repo.getLibraryLayout(libname),
95
- (layout) => {
96
- if (layout === 2) {
97
- return false;
98
- } else {
99
- return repo.setLibraryLayout(libname, 2)
100
- .then(() => {
101
- if (site.isAdaptersRequired()) {
102
- return buildAdapters(libdir, libname);
103
- }
104
- })
105
- .then(() => true);
106
- }
107
- }
108
- ]));
86
+ async processLibrary(repo, libname, state, site, libdir) {
87
+ return resultError(this._processLibrary(repo, libname, state, site, libdir));
88
+ }
89
+
90
+ async _processLibrary(repo, libname, state, site, libdir) {
91
+ const layout = await repo.getLibraryLayout(libname);
92
+ if (layout === 2) {
93
+ return false;
94
+ }
95
+ await repo.setLibraryLayout(libname, 2);
96
+ if (site.isAdaptersRequired()) {
97
+ await buildAdapters(libdir, libname);
98
+ }
99
+ return true;
109
100
  }
110
101
  }
@@ -29,7 +29,7 @@ void loop() {
29
29
  // The core of your code will likely live here.
30
30
 
31
31
  // Example: Publish event to cloud every 10 seconds. Uncomment the next 3 lines to try it!
32
- // Logging.info("Sending Hello World to the cloud!");
32
+ // Log.info("Sending Hello World to the cloud!");
33
33
  // Particle.publish("Hello world!");
34
34
  // delay( 10 * 1000 ); // milliseconds and blocking - see docs for more info!
35
35
  }