particle-commands 0.2.12 → 0.4.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/.circleci/config.yml +68 -0
- package/.eslintrc +1 -2
- package/.nvmrc +1 -0
- package/CHANGELOG.md +11 -0
- package/README.md +93 -1
- package/dist/cmd/library_add.js +1 -14
- package/dist/cmd/library_contribute.js +0 -10
- package/dist/cmd/library_install.js +11 -26
- package/dist/cmd/library_migrate.js +3 -4
- package/dist/cmd/library_properties.js +3 -4
- package/dist/cmd/library_publish.js +0 -8
- package/dist/cmd/project_init.js +0 -3
- package/dist/cmd/project_properties.js +9 -12
- package/dist/cmd/templates/project/README.md +2 -2
- package/dist/index.js +9 -28
- package/package.json +20 -20
- package/src/cmd/library_add.js +2 -8
- package/src/cmd/library_contribute.js +0 -3
- package/src/cmd/library_install.js +7 -16
- package/src/cmd/library_publish.js +0 -3
- package/src/cmd/project_init.js +1 -3
- package/src/cmd/templates/project/README.md +2 -2
- package/src/index.js +0 -8
- package/test/cmd/library_install.spec.js +1 -1
- package/test/cmd/library_list.spec.js +5 -9
- package/test/cmd/library_publish.spec.js +1 -1
- package/test/cmd/project_init.spec.js +1 -4
- package/test/cmd/projects_spec.js +4 -4
- package/.idea/jsLibraryMappings.xml +0 -6
- package/.idea/misc.xml +0 -13
- package/.idea/modules.xml +0 -8
- package/.idea/particle-commands.iml +0 -12
- package/.idea/vcs.xml +0 -6
- package/.idea/workspace.xml +0 -222
- package/.npmignore +0 -1
- package/.travis.yml +0 -2
- package/dist/lib/analytics.js +0 -229
- package/dist/lib/settings.js +0 -410
- package/dist/lib/utilities.js +0 -27
- package/src/lib/analytics.js +0 -182
- package/src/lib/settings.js +0 -359
- package/src/lib/utilities.js +0 -24
- package/test/lib/analytics.spec.js +0 -158
- package/test/lib/settings.spec.js +0 -27
- package/yarn.lock +0 -4690
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
version: 2.1
|
|
2
|
+
|
|
3
|
+
jobs:
|
|
4
|
+
run-tests:
|
|
5
|
+
parameters:
|
|
6
|
+
node-version:
|
|
7
|
+
type: string
|
|
8
|
+
docker:
|
|
9
|
+
- image: cimg/node:<< parameters.node-version >> # Primary execution image
|
|
10
|
+
auth:
|
|
11
|
+
username: $DOCKERHUB_USERNAME
|
|
12
|
+
password: $DOCKERHUB_PASSWORD
|
|
13
|
+
steps:
|
|
14
|
+
- checkout
|
|
15
|
+
- run:
|
|
16
|
+
name: NPM install
|
|
17
|
+
command: npm ci
|
|
18
|
+
- run:
|
|
19
|
+
name: Run tests with coverage
|
|
20
|
+
command: npm run test:ci
|
|
21
|
+
publish-npm:
|
|
22
|
+
docker:
|
|
23
|
+
- image: cimg/node:16.15.0 # Primary execution image
|
|
24
|
+
auth:
|
|
25
|
+
username: $DOCKERHUB_USERNAME
|
|
26
|
+
password: $DOCKERHUB_PASSWORD
|
|
27
|
+
steps:
|
|
28
|
+
- checkout
|
|
29
|
+
- run:
|
|
30
|
+
name: NPM install
|
|
31
|
+
command: npm ci
|
|
32
|
+
- run:
|
|
33
|
+
name: Authenticate with NPM
|
|
34
|
+
command: npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
|
|
35
|
+
- run:
|
|
36
|
+
name: Publish package
|
|
37
|
+
command: |
|
|
38
|
+
# Publish as beta for pre-release tags like v1.2.3-pre.1
|
|
39
|
+
[[ $CIRCLE_TAG =~ ^v.*- ]] && NPM_TAG=--tag=beta
|
|
40
|
+
npm publish $NPM_TAG
|
|
41
|
+
|
|
42
|
+
workflows:
|
|
43
|
+
version: 2
|
|
44
|
+
test-and-publish:
|
|
45
|
+
jobs:
|
|
46
|
+
- run-tests:
|
|
47
|
+
context:
|
|
48
|
+
- particle-ci-private
|
|
49
|
+
matrix:
|
|
50
|
+
parameters:
|
|
51
|
+
node-version: ["12.22.12", "14.19.2", "16.15.0"]
|
|
52
|
+
# run tests for all branches and tags
|
|
53
|
+
filters:
|
|
54
|
+
tags:
|
|
55
|
+
only: /^v.*/
|
|
56
|
+
branches:
|
|
57
|
+
only: /.*/
|
|
58
|
+
- publish-npm:
|
|
59
|
+
requires:
|
|
60
|
+
- run-tests
|
|
61
|
+
context:
|
|
62
|
+
- particle-ci-private
|
|
63
|
+
# publish for tags only
|
|
64
|
+
filters:
|
|
65
|
+
tags:
|
|
66
|
+
only: /^v.*/
|
|
67
|
+
branches:
|
|
68
|
+
ignore: /.*/
|
package/.eslintrc
CHANGED
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
16
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
### 0.4.0 - 2022-05-31
|
|
7
|
+
- Move to `node@16` and `npm@8` for local development
|
|
8
|
+
|
|
9
|
+
### 0.3.0 - 2018-09-06
|
|
10
|
+
### Change
|
|
11
|
+
- revert changes for analytics
|
|
12
|
+
|
|
13
|
+
### 0.2.13 - 2018-09-06
|
|
14
|
+
### Fix
|
|
15
|
+
- allow single letter project names
|
|
16
|
+
|
|
6
17
|
### 0.2.12 - 2017-07-10
|
|
7
18
|
### Changed
|
|
8
19
|
- adds support for analytics
|
package/README.md
CHANGED
|
@@ -1,2 +1,94 @@
|
|
|
1
|
-
# Particle Commands
|
|
1
|
+
# Particle Commands
|
|
2
2
|
UX-neutral commands for developer tools
|
|
3
|
+
|
|
4
|
+
[](https://app.circleci.com/pipelines/github/particle-iot/particle-commands)
|
|
5
|
+
|
|
6
|
+
[Installation](#installation) | [Development](#development) | [Conventions](#conventions) | [Docs](#docs--resources) | [Releasing](#releasing) | [License](#license)
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
1. Install Node.js [`node@16.x` and `npm@8.x` are required]
|
|
10
|
+
1. Clone this repository `$ git clone git@github.com:particle-iot/particle-commands.git && cd ./particle-commands`
|
|
11
|
+
1. Install dependencies `$ npm install`
|
|
12
|
+
1. View available commands `$ npm run`
|
|
13
|
+
1. Run the tests `$ npm test`
|
|
14
|
+
1. Start Hacking!
|
|
15
|
+
|
|
16
|
+
## Development
|
|
17
|
+
|
|
18
|
+
All essential commands are available at the root via `npm run <script name>` - e.g. `npm run lint`. To view the available commands, run: `npm run`
|
|
19
|
+
|
|
20
|
+
<details id="develop-run-tests">
|
|
21
|
+
<summary><b>How to run your tests</b></summary>
|
|
22
|
+
<p>
|
|
23
|
+
|
|
24
|
+
to run the tests:
|
|
25
|
+
|
|
26
|
+
`npm test`
|
|
27
|
+
|
|
28
|
+
to run the coverage:
|
|
29
|
+
|
|
30
|
+
`npm run coverage`
|
|
31
|
+
|
|
32
|
+
</p>
|
|
33
|
+
</details>
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
<details id="develop-npm-scripts">
|
|
37
|
+
<summary><b>How to name npm scripts</b></summary>
|
|
38
|
+
<p>
|
|
39
|
+
|
|
40
|
+
npm scripts are the primary means of executing programmatic tasks (e.g. tests, linting, releasing, etc) within the repo. to view available scripts, run `npm run`.
|
|
41
|
+
|
|
42
|
+
when creating a new script, be sure it does not already exist and use the following naming convention:
|
|
43
|
+
|
|
44
|
+
`<category>:[<subcategory>]:[<action>]`
|
|
45
|
+
|
|
46
|
+
our standard categories include: `test`, `lint`, `build`, `clean`, `docs`, `package`, `dependencies`, and `release`. top-level scripts - e.g. `npm run clean` - will typically run all of its subcategories (e.g. `npm run clean:dist && npm run clean:tmp`).
|
|
47
|
+
|
|
48
|
+
`npm` itself includes special handling for `test` and `start` (doc: [1](https://docs.npmjs.com/cli/v6/commands/npm-test), [2](https://docs.npmjs.com/cli/v6/commands/npm-start)) amongst other [lifecycle scripts](https://docs.npmjs.com/cli/v7/using-npm/scripts#life-cycle-scripts) - use these to expose key testing and start-up commands.
|
|
49
|
+
|
|
50
|
+
sometimes your new script will be very similar to an existing script. in those cases, try to extend the existing script before adding another one.
|
|
51
|
+
|
|
52
|
+
</p>
|
|
53
|
+
</details>
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
## Conventions
|
|
57
|
+
|
|
58
|
+
* [npm scripts](https://docs.npmjs.com/misc/scripts) form the _developer's API_ for the repo and all of its packages - key orchestration commands should be exposed here
|
|
59
|
+
* document developer-facing process / tooling instructions in the [Development](#development) section
|
|
60
|
+
* plan to release your changes upon merging to `main` - refrain from merging if you cannot so you don't leave unpublished changes to others
|
|
61
|
+
* avoid making changes in files unrelated to the work you are doing so you aren't having to publish trivial updates
|
|
62
|
+
* test files live alongside their source files and are named like `*.test.js` or `*.spec.js`
|
|
63
|
+
* if the linter does not flag your code (error or warning), it's formatted properly
|
|
64
|
+
* avoid reformatting unflagged code as it can obscure more meaningful changes and increase the chance of merge conflicts
|
|
65
|
+
* todo comments include your last name and are formatted like: `TODO (mirande): <message>`
|
|
66
|
+
|
|
67
|
+
## Docs & Resources
|
|
68
|
+
|
|
69
|
+
* [Mocha](https://mochajs.org/)
|
|
70
|
+
* [Chai](http://www.chaijs.com/api/bdd/)
|
|
71
|
+
* [Sinon](https://sinonjs.org/)
|
|
72
|
+
* [NYC](https://github.com/istanbuljs/nyc)
|
|
73
|
+
|
|
74
|
+
## Releasing
|
|
75
|
+
|
|
76
|
+
Packages are only released from the `main` branch after peer review.
|
|
77
|
+
|
|
78
|
+
1. make sure you have the latest:
|
|
79
|
+
* `$ git checkout main`
|
|
80
|
+
* `$ git pull`
|
|
81
|
+
1. make sure tests pass
|
|
82
|
+
* `$ npm test`
|
|
83
|
+
1. run the version command
|
|
84
|
+
* `$ npm version <major|minor|patch>`
|
|
85
|
+
* This command will bump the current version of the library in the `package.json` file. Before the command finishes, update `CHANGELOG.md`.
|
|
86
|
+
1. push your tags:
|
|
87
|
+
* `$ git push origin main --follow-tags`
|
|
88
|
+
1. CircleCI will publish the npm package to the `latest` tag
|
|
89
|
+
1. Create a release on GitHub with the notes from the `CHANGELOG.md`
|
|
90
|
+
1. Point your project to the new version `npm install particle-commands@latest`
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
Copyright © 2016 Particle Industries, Inc. Released under the Apache 2.0 license. See [LICENSE](/LICENSE) for details.
|
package/dist/cmd/library_add.js
CHANGED
|
@@ -17,12 +17,6 @@ var _command = require('./command');
|
|
|
17
17
|
|
|
18
18
|
var _library = require('./library');
|
|
19
19
|
|
|
20
|
-
var _analytics = require('../lib/analytics');
|
|
21
|
-
|
|
22
|
-
var analytics = _interopRequireWildcard(_analytics);
|
|
23
|
-
|
|
24
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
25
|
-
|
|
26
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
21
|
|
|
28
22
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -95,23 +89,16 @@ var LibraryAddCommand = exports.LibraryAddCommand = function () {
|
|
|
95
89
|
lib.version = 'latest';
|
|
96
90
|
}
|
|
97
91
|
var directory = this.site.projectDir();
|
|
98
|
-
var library = void 0;
|
|
99
92
|
return (0, _pipeline2.default)([function () {
|
|
100
93
|
return _this2.ensureProjectExists(directory);
|
|
101
94
|
}, function () {
|
|
102
95
|
return _this2.loadProject();
|
|
103
96
|
}, function () {
|
|
104
97
|
return _this2.fetchLibrary(lib.name, lib.version);
|
|
105
|
-
}, function (
|
|
106
|
-
return library = library_;
|
|
107
|
-
}, function () {
|
|
98
|
+
}, function (library) {
|
|
108
99
|
return _this2.addLibraryToProject(library);
|
|
109
100
|
}, function () {
|
|
110
101
|
return _this2.saveProject();
|
|
111
|
-
}, function () {
|
|
112
|
-
return analytics.track({ command: _this2, context: state, site: site, event: 'library added',
|
|
113
|
-
properties: { name: lib.name, version: lib.version, actualName: library.name, actualVersion: library.version,
|
|
114
|
-
projectName: _this2.properties.getField('name') } });
|
|
115
102
|
}]);
|
|
116
103
|
}
|
|
117
104
|
}, {
|
|
@@ -11,12 +11,6 @@ var _command = require('./command');
|
|
|
11
11
|
|
|
12
12
|
var _particleLibraryManager = require('particle-library-manager');
|
|
13
13
|
|
|
14
|
-
var _analytics = require('../lib/analytics');
|
|
15
|
-
|
|
16
|
-
var analytics = _interopRequireWildcard(_analytics);
|
|
17
|
-
|
|
18
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
19
|
-
|
|
20
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
15
|
|
|
22
16
|
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; }
|
|
@@ -115,8 +109,6 @@ var LibraryContributeCommand = exports.LibraryContributeCommand = function (_Com
|
|
|
115
109
|
* @returns {Promise} To run the library contribute command.
|
|
116
110
|
*/
|
|
117
111
|
value: function run(state, site) {
|
|
118
|
-
var _this3 = this;
|
|
119
|
-
|
|
120
112
|
var events = function events(event) {
|
|
121
113
|
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
122
114
|
args[_key - 1] = arguments[_key];
|
|
@@ -140,8 +132,6 @@ var LibraryContributeCommand = exports.LibraryContributeCommand = function (_Com
|
|
|
140
132
|
var repo = new _particleLibraryManager.FileSystemLibraryRepository(contributeDir, _particleLibraryManager.FileSystemNamingStrategy.DIRECT);
|
|
141
133
|
return repo.contribute(name, client, dryRun, events);
|
|
142
134
|
}).catch(function (err) {
|
|
143
|
-
analytics.track({ command: _this3, context: state, site: site, event: 'library upload failed',
|
|
144
|
-
properties: { name: name, error: err } });
|
|
145
135
|
if (err.validate && site.validationError) {
|
|
146
136
|
site.validationError(err);
|
|
147
137
|
} else {
|
|
@@ -29,12 +29,6 @@ var _library = require('./library');
|
|
|
29
29
|
|
|
30
30
|
var _projects = require('./projects');
|
|
31
31
|
|
|
32
|
-
var _analytics = require('../lib/analytics');
|
|
33
|
-
|
|
34
|
-
var analytics = _interopRequireWildcard(_analytics);
|
|
35
|
-
|
|
36
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
37
|
-
|
|
38
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
33
|
|
|
40
34
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -205,16 +199,14 @@ var LibraryInstallCommand = exports.LibraryInstallCommand = function (_Command)
|
|
|
205
199
|
// the directory containing the target project
|
|
206
200
|
var targetDir = site.targetDirectory();
|
|
207
201
|
|
|
208
|
-
var _split = (site.libraryName() || '').split('@')
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
var libName = _split2[0];
|
|
213
|
-
var libVersion = _split2[1];
|
|
202
|
+
var _split = (site.libraryName() || '').split('@'),
|
|
203
|
+
_split2 = _slicedToArray(_split, 2),
|
|
204
|
+
libName = _split2[0],
|
|
205
|
+
libVersion = _split2[1];
|
|
214
206
|
|
|
215
207
|
var client = site.apiClient();
|
|
216
208
|
var cloudRepo = new _particleLibraryManager.CloudLibraryRepository({ client: client });
|
|
217
|
-
var context = {
|
|
209
|
+
var context = {};
|
|
218
210
|
var vendored = site.isVendored();
|
|
219
211
|
var properties = void 0;
|
|
220
212
|
if (!vendored && !libName) {
|
|
@@ -268,18 +260,17 @@ var LibraryInstallCommand = exports.LibraryInstallCommand = function (_Command)
|
|
|
268
260
|
* @param {ProjectProperties} project The project properties for the project being installed to.
|
|
269
261
|
* Only defined when vendored is true.
|
|
270
262
|
* @param {object} context The current operation context.
|
|
271
|
-
* @param {Number} dependencyDepth the depth in the dependency hierarchy this library is at.
|
|
272
|
-
* Direct project dependencies are at depth 0.
|
|
273
263
|
* @returns {Promise|Promise.<TResult>} A promise to install the library and dependents.
|
|
274
264
|
* @private
|
|
275
265
|
*/
|
|
276
266
|
|
|
277
267
|
}, {
|
|
278
268
|
key: '_installLib',
|
|
279
|
-
value: function _installLib(site, cloudRepo, vendored, libName, libVersion, libraryTargetStrategy, project, context
|
|
269
|
+
value: function _installLib(site, cloudRepo, vendored, libName, libVersion, libraryTargetStrategy, project, context) {
|
|
280
270
|
var _this5 = this;
|
|
281
271
|
|
|
282
272
|
context[libName] = libVersion || 'latest';
|
|
273
|
+
|
|
283
274
|
return site.notifyCheckingLibrary(libName).then(function () {
|
|
284
275
|
return cloudRepo.fetch(libName, libVersion);
|
|
285
276
|
}).then(function (lib) {
|
|
@@ -293,11 +284,7 @@ var LibraryInstallCommand = exports.LibraryInstallCommand = function (_Command)
|
|
|
293
284
|
}).then(function () {
|
|
294
285
|
return site.notifyInstalledLibrary(lib.metadata, libDir);
|
|
295
286
|
}).then(function () {
|
|
296
|
-
return
|
|
297
|
-
properties: { name: libName, version: libVersion, actualName: lib.metadata.name,
|
|
298
|
-
actualVersion: lib.metadata.version, dependencyDepth: dependencyDepth, projectName: project && project.name } });
|
|
299
|
-
}).then(function () {
|
|
300
|
-
return _this5._installDependents(site, cloudRepo, vendored, libraryTargetStrategy, project, context, libDir, dependencyDepth + 1);
|
|
287
|
+
return _this5._installDependents(site, cloudRepo, vendored, libraryTargetStrategy, project, context, libDir);
|
|
301
288
|
});
|
|
302
289
|
});
|
|
303
290
|
}
|
|
@@ -311,15 +298,13 @@ var LibraryInstallCommand = exports.LibraryInstallCommand = function (_Command)
|
|
|
311
298
|
* @param {ProjectProperties} project The project being installed to.
|
|
312
299
|
* @param {object} context The current operation context - used to avoid infinite recursion in the event of cyclic dependencies.
|
|
313
300
|
* @param {String} libDir The directory containing the library whose dependences should be installed.
|
|
314
|
-
* @param {Number} dependencyDepth How deep the dependency tree is. Project libraries are at depth 0, their dependents
|
|
315
|
-
* at depth 1 etc..
|
|
316
301
|
* @returns {*|Promise|Promise.<TResult>} returns a promise to install all library dependents
|
|
317
302
|
* @private
|
|
318
303
|
*/
|
|
319
304
|
|
|
320
305
|
}, {
|
|
321
306
|
key: '_installDependents',
|
|
322
|
-
value: function _installDependents(site, cloudRepo, vendored, libraryTargetStrategy, project, context, libDir
|
|
307
|
+
value: function _installDependents(site, cloudRepo, vendored, libraryTargetStrategy, project, context, libDir) {
|
|
323
308
|
var _this6 = this;
|
|
324
309
|
|
|
325
310
|
var libraryProperties = new _library_properties2.default(libDir);
|
|
@@ -330,7 +315,7 @@ var LibraryInstallCommand = exports.LibraryInstallCommand = function (_Command)
|
|
|
330
315
|
var dependencyVersion = dependencies[dependencyName];
|
|
331
316
|
if (!context[dependencyName]) {
|
|
332
317
|
context[dependencyName] = dependencyVersion;
|
|
333
|
-
resolve.push(_this6._installLib(site, cloudRepo, vendored, dependencyName, dependencyVersion, libraryTargetStrategy, project, context
|
|
318
|
+
resolve.push(_this6._installLib(site, cloudRepo, vendored, dependencyName, dependencyVersion, libraryTargetStrategy, project, context));
|
|
334
319
|
}
|
|
335
320
|
}
|
|
336
321
|
return Promise.all(resolve);
|
|
@@ -362,7 +347,7 @@ var LibraryInstallCommand = exports.LibraryInstallCommand = function (_Command)
|
|
|
362
347
|
if (vendored && layout !== _project_properties.extended) {
|
|
363
348
|
return site.notifyIncorrectLayout(layout, _project_properties.extended, libName, installTarget(libName, libVersion));
|
|
364
349
|
} else {
|
|
365
|
-
return _this7._installLib(site, cloudRepo, vendored, libName, libVersion, installTarget, project, context
|
|
350
|
+
return _this7._installLib(site, cloudRepo, vendored, libName, libVersion, installTarget, project, context);
|
|
366
351
|
}
|
|
367
352
|
});
|
|
368
353
|
}
|
|
@@ -114,10 +114,9 @@ var AbstractLibraryMigrateCommand = function (_Command) {
|
|
|
114
114
|
var dir = _path2.default.resolve(libdir);
|
|
115
115
|
var repo = new _particleLibraryManager.FileSystemLibraryRepository(dir, _particleLibraryManager.FileSystemNamingStrategy.DIRECT);
|
|
116
116
|
return _this3.processLibrary(repo, '', state, site, libdir).then(function (_ref) {
|
|
117
|
-
var _ref2 = _slicedToArray(_ref, 2)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
var err = _ref2[1];
|
|
117
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
118
|
+
res = _ref2[0],
|
|
119
|
+
err = _ref2[1];
|
|
121
120
|
|
|
122
121
|
return Promise.resolve(site.notifyEnd(libdir, res, err)).then(function () {
|
|
123
122
|
return { libdir: libdir, res: res, err: err };
|
|
@@ -40,10 +40,9 @@ var LibraryProperties = function (_ProjectProperties) {
|
|
|
40
40
|
_inherits(LibraryProperties, _ProjectProperties);
|
|
41
41
|
|
|
42
42
|
function LibraryProperties(dir) {
|
|
43
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var filename = _ref$filename === undefined ? 'library.properties' : _ref$filename;
|
|
43
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
44
|
+
_ref$filename = _ref.filename,
|
|
45
|
+
filename = _ref$filename === undefined ? 'library.properties' : _ref$filename;
|
|
47
46
|
|
|
48
47
|
_classCallCheck(this, LibraryProperties);
|
|
49
48
|
|
|
@@ -11,12 +11,6 @@ var _command = require('./command');
|
|
|
11
11
|
|
|
12
12
|
var _api = require('./api');
|
|
13
13
|
|
|
14
|
-
var _analytics = require('../lib/analytics');
|
|
15
|
-
|
|
16
|
-
var analytics = _interopRequireWildcard(_analytics);
|
|
17
|
-
|
|
18
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
19
|
-
|
|
20
14
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
15
|
|
|
22
16
|
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; }
|
|
@@ -119,8 +113,6 @@ var LibraryPublishCommand = exports.LibraryPublishCommand = function (_Command)
|
|
|
119
113
|
site.publishLibraryComplete(library);
|
|
120
114
|
return library;
|
|
121
115
|
}).catch(function (err) {
|
|
122
|
-
analytics.track({ command: _this3, context: state, site: site, event: 'library publish failed',
|
|
123
|
-
properties: { name: name, error: err } });
|
|
124
116
|
site.error(err);
|
|
125
117
|
});
|
|
126
118
|
});
|
package/dist/cmd/project_init.js
CHANGED
|
@@ -34,7 +34,6 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
|
|
34
34
|
var promisify = require('es6-promisify');
|
|
35
35
|
|
|
36
36
|
var underscore = require('underscore');
|
|
37
|
-
var analytics = require('../lib/analytics');
|
|
38
37
|
|
|
39
38
|
/**
|
|
40
39
|
* Specification and base implementation for the site instance expected by
|
|
@@ -218,8 +217,6 @@ var ProjectInitCommand = exports.ProjectInitCommand = function (_Command) {
|
|
|
218
217
|
project = site.notifyCreatingProject(directory, project) || project;
|
|
219
218
|
return project.then(function () {
|
|
220
219
|
return site.notifyProjectCreated(directory);
|
|
221
|
-
}).then(function () {
|
|
222
|
-
return analytics.track({ command: _this4, context: state, site: site, event: 'project created', properties: { 'projectName': name } });
|
|
223
220
|
});
|
|
224
221
|
} else {
|
|
225
222
|
return site.notifyProjectNotCreated(directory);
|
|
@@ -50,12 +50,11 @@ var ProjectProperties = function () {
|
|
|
50
50
|
}]);
|
|
51
51
|
|
|
52
52
|
function ProjectProperties(dir) {
|
|
53
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
var fs = _ref$fs === undefined ? buildPromisefs() : _ref$fs;
|
|
53
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
54
|
+
_ref$filename = _ref.filename,
|
|
55
|
+
filename = _ref$filename === undefined ? 'project.properties' : _ref$filename,
|
|
56
|
+
_ref$fs = _ref.fs,
|
|
57
|
+
fs = _ref$fs === undefined ? buildPromisefs() : _ref$fs;
|
|
59
58
|
|
|
60
59
|
_classCallCheck(this, ProjectProperties);
|
|
61
60
|
|
|
@@ -86,12 +85,10 @@ var ProjectProperties = function () {
|
|
|
86
85
|
var _this2 = this;
|
|
87
86
|
|
|
88
87
|
this.fields = data.split('\n').reduce(function (obj, line) {
|
|
89
|
-
var _line$split = line.split('=')
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
var field = _line$split2[0];
|
|
94
|
-
var value = _line$split2[1];
|
|
88
|
+
var _line$split = line.split('='),
|
|
89
|
+
_line$split2 = _slicedToArray(_line$split, 2),
|
|
90
|
+
field = _line$split2[0],
|
|
91
|
+
value = _line$split2[1];
|
|
95
92
|
|
|
96
93
|
if (field && value !== undefined) {
|
|
97
94
|
field = field.trim();
|
|
@@ -24,7 +24,7 @@ This is the file that specifies the name and version number of the libraries tha
|
|
|
24
24
|
If you would like add additional files to your application, they should be added to the `/src` folder. All files in the `/src` folder will be sent to the Particle Cloud to produce a compiled binary.
|
|
25
25
|
|
|
26
26
|
#### Projects with external libraries
|
|
27
|
-
If your project includes a library that has not been registered in the Particle libraries system, you should create a new folder named `/lib/<libraryname>/src` under `/<project dir>` and add the `.h
|
|
27
|
+
If your project includes a library that has not been registered in the Particle libraries system, you should create a new folder named `/lib/<libraryname>/src` under `/<project dir>` and add the `.h`, `.cpp` & `library.properties` files for your library there. Read the [Firmware Libraries guide](https://docs.particle.io/guide/tools-and-features/libraries/) for more details on how to develop libraries. Note that all contents of the `/lib` folder and subfolders will also be sent to the Cloud for compilation.
|
|
28
28
|
|
|
29
29
|
## Compiling your project
|
|
30
30
|
|
|
@@ -32,4 +32,4 @@ When you're ready to compile your project, make sure you have the correct Partic
|
|
|
32
32
|
|
|
33
33
|
- Everything in the `/src` folder, including your `.ino` application file
|
|
34
34
|
- The `project.properties` file for your project
|
|
35
|
-
- Any libraries stored under `lib/<libraryname>/src`
|
|
35
|
+
- Any libraries stored under `lib/<libraryname>/src`
|
package/dist/index.js
CHANGED
|
@@ -1,36 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
4
|
+
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.settings = exports.utilities = exports.analytics = undefined;
|
|
7
6
|
|
|
8
7
|
var _index = require('./cmd/index');
|
|
9
8
|
|
|
10
9
|
Object.keys(_index).forEach(function (key) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
var _analytics = require('./lib/analytics');
|
|
21
|
-
|
|
22
|
-
var analytics = _interopRequireWildcard(_analytics);
|
|
23
|
-
|
|
24
|
-
var _utilities = require('./lib/utilities');
|
|
25
|
-
|
|
26
|
-
var utilities = _interopRequireWildcard(_utilities);
|
|
27
|
-
|
|
28
|
-
var _settings = require('./lib/settings');
|
|
29
|
-
|
|
30
|
-
var settings = _interopRequireWildcard(_settings);
|
|
31
|
-
|
|
32
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
33
|
-
|
|
34
|
-
exports.analytics = analytics;
|
|
35
|
-
exports.utilities = utilities;
|
|
36
|
-
exports.settings = settings;
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
Object.defineProperty(exports, key, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function get() {
|
|
14
|
+
return _index[key];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"author": "Matthew McGowan",
|
|
6
6
|
"bugs": {
|
|
7
|
-
"url": "https://github.com/
|
|
7
|
+
"url": "https://github.com/particle-iot/particle-commands/issues"
|
|
8
8
|
},
|
|
9
9
|
"contributors": [
|
|
10
10
|
{
|
|
@@ -13,13 +13,11 @@
|
|
|
13
13
|
}
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"analytics-node": "^2.4.0",
|
|
17
16
|
"babel-runtime": "^6.9.2",
|
|
18
17
|
"es6-promisify": "^4.1.0",
|
|
19
|
-
"glob": "^7.1.1",
|
|
20
18
|
"mkdirp": "^0.5.1",
|
|
21
19
|
"particle-api-js": "^6.5.0",
|
|
22
|
-
"particle-library-manager": "^0.1.
|
|
20
|
+
"particle-library-manager": "^0.1.13",
|
|
23
21
|
"semver": "^5.1.0",
|
|
24
22
|
"underscore": "^1.8.3",
|
|
25
23
|
"when": "^3.7.2",
|
|
@@ -42,9 +40,9 @@
|
|
|
42
40
|
"eslint": "~2.2.0",
|
|
43
41
|
"eslint-config-particle": "^1.0.1",
|
|
44
42
|
"fs-extra": "^0.30.0",
|
|
45
|
-
"istanbul": "^0.3.22",
|
|
46
43
|
"mocha": "^3.0.2",
|
|
47
|
-
"mock-fs": "^
|
|
44
|
+
"mock-fs": "^5.1.2",
|
|
45
|
+
"nyc": "^15.1.0",
|
|
48
46
|
"proxyquire": "^1.6.0",
|
|
49
47
|
"rimraf-promise": "^2.0.0",
|
|
50
48
|
"sinon": "^1.15.4",
|
|
@@ -54,10 +52,7 @@
|
|
|
54
52
|
"testdouble-chai": "^0.2.2",
|
|
55
53
|
"tmp": "0.0.28"
|
|
56
54
|
},
|
|
57
|
-
"
|
|
58
|
-
"node": ">=0.10.40"
|
|
59
|
-
},
|
|
60
|
-
"homepage": "https://github.com/spark/particle-commands/",
|
|
55
|
+
"homepage": "https://github.com/particle-iot/particle-commands/",
|
|
61
56
|
"keywords": [
|
|
62
57
|
"cli",
|
|
63
58
|
"core",
|
|
@@ -72,22 +67,27 @@
|
|
|
72
67
|
"preferGlobal": false,
|
|
73
68
|
"repository": {
|
|
74
69
|
"type": "git",
|
|
75
|
-
"url": "https://github.com/
|
|
70
|
+
"url": "https://github.com/particle-iot/particle-commands"
|
|
76
71
|
},
|
|
77
72
|
"scripts": {
|
|
78
|
-
"
|
|
73
|
+
"prepublish": "npm run compile",
|
|
74
|
+
"preversion": "npm run lint && npm run test && npm run prepublish",
|
|
75
|
+
"version": "npm run update-changelog",
|
|
76
|
+
"compile": "babel src -d dist --copy-files",
|
|
79
77
|
"babel-watch": "babel src -d dist --watch --source-maps --copy-files",
|
|
80
|
-
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec test/ --compilers js:babel-register",
|
|
81
|
-
"coveralls": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec --compilers js:babel-register test/ && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
|
|
82
78
|
"doctoc": "doctoc --title '## Table of Contents' README.md",
|
|
83
79
|
"list-folders": "node --require babel-register bin/list_folders.js",
|
|
80
|
+
"test": "npm run lint && npm run test:unit",
|
|
81
|
+
"test:ci": "npm run lint && npm run test:unit -- --forbid-only && npm run coverage",
|
|
82
|
+
"test:unit": "mocha test test/cmd test/integration --compilers js:babel-register",
|
|
83
|
+
"test:unit:silent": "npm run test:unit > tmp/test-unit-log.txt 2>&1",
|
|
84
84
|
"lint": "eslint -f unix src/**/*.js",
|
|
85
85
|
"lint:fix": "eslint --fix -f unix src/ test/",
|
|
86
|
-
"
|
|
87
|
-
"compile": "babel src -d dist --copy-files",
|
|
88
|
-
"prepublish": "npm run compile",
|
|
89
|
-
"preversion": "npm run lint && npm run test && npm run prepublish",
|
|
90
|
-
"version": "npm run update-changelog",
|
|
86
|
+
"coverage": "nyc --reporter=text --include='src/**/*.js' --temp-dir=./tmp/ --check-coverage --lines 50 npm run test:unit:silent",
|
|
91
87
|
"update-changelog": "VERSION=`node -p -e \"require('./package.json').version\"` bash -c 'read -p \"Update CHANGELOG.md for version $VERSION and press ENTER when done.\"' && git add CHANGELOG.md"
|
|
88
|
+
},
|
|
89
|
+
"engines": {
|
|
90
|
+
"node": ">=12.x",
|
|
91
|
+
"npm": "8.x"
|
|
92
92
|
}
|
|
93
93
|
}
|
package/src/cmd/library_add.js
CHANGED
|
@@ -3,7 +3,6 @@ import pipeline from 'when/pipeline';
|
|
|
3
3
|
import { convertApiError } from './api';
|
|
4
4
|
import { CommandSite } from './command';
|
|
5
5
|
import { findProject } from './library';
|
|
6
|
-
import * as analytics from '../lib/analytics';
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
|
|
@@ -46,17 +45,12 @@ export class LibraryAddCommand {
|
|
|
46
45
|
lib.version = 'latest';
|
|
47
46
|
}
|
|
48
47
|
const directory = this.site.projectDir();
|
|
49
|
-
let library;
|
|
50
48
|
return pipeline([
|
|
51
49
|
() => this.ensureProjectExists(directory),
|
|
52
50
|
() => this.loadProject(),
|
|
53
51
|
() => this.fetchLibrary(lib.name, lib.version),
|
|
54
|
-
(
|
|
55
|
-
() => this.
|
|
56
|
-
() => this.saveProject(),
|
|
57
|
-
() => analytics.track({ command:this, context: state, site, event: 'library added',
|
|
58
|
-
properties: { name: lib.name, version: lib.version, actualName: library.name, actualVersion: library.version,
|
|
59
|
-
projectName: this.properties.getField('name') } })
|
|
52
|
+
(library) => this.addLibraryToProject(library),
|
|
53
|
+
() => this.saveProject()
|
|
60
54
|
]);
|
|
61
55
|
}
|
|
62
56
|
|