particle-commands 1.0.5 → 1.0.6

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,9 @@
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.6 - 2026-01-30
7
+ - Include env in project.properties for new project
8
+
6
9
  ### 1.0.5 - 2025-10-21
7
10
  - Bump to exclusive >= node 22
8
11
  - Migrate to latest particle eslint config
@@ -251,9 +251,9 @@ var ProjectInitCommand = exports.ProjectInitCommand = function (_Command) {
251
251
  }
252
252
  }, {
253
253
  key: 'createNotifyTemplateIfNeeded',
254
- value: function createNotifyTemplateIfNeeded(site, fs, targetFile, templateName, data) {
254
+ value: async function createNotifyTemplateIfNeeded(site, fs, targetFile, templateName, data) {
255
255
  // assumes the parent directory of the template exists
256
- var content = this.expandTemplate(fs, templateName, data);
256
+ var content = await this.expandTemplate(fs, templateName, data);
257
257
  return this.createNotifyFileIfNeeded(site, fs, targetFile, content);
258
258
  }
259
259
 
@@ -316,7 +316,7 @@ var ProjectInitCommand = exports.ProjectInitCommand = function (_Command) {
316
316
  return project.save();
317
317
  }
318
318
  }).then(function () {
319
- return project.writeAssetOtaDir();
319
+ return project.populateProjectProperties();
320
320
  });
321
321
  }
322
322
 
@@ -121,17 +121,23 @@ var ProjectProperties = function () {
121
121
  return this.fs.writeFile(this.name(), data, 'utf8');
122
122
  }
123
123
  }, {
124
- key: 'writeAssetOtaDir',
125
- value: function writeAssetOtaDir() {
124
+ key: 'populateProjectProperties',
125
+ value: function populateProjectProperties() {
126
126
  var _this3 = this;
127
127
 
128
- // // Add a commented line for assetOtaDir if it doesn't exist
129
- this.load().then(function () {
128
+ // Add a commented line for assetOtaDir and env if they don't exist
129
+ return this.load().then(function () {
130
130
  var val = _this3.getField('#assetOtaDir');
131
131
  if (!val) {
132
132
  _this3.setField('#assetOtaDir', 'assets');
133
133
  return _this3.save();
134
134
  }
135
+ }).then(function () {
136
+ var val = _this3.getField('#env');
137
+ if (!val) {
138
+ _this3.setField('#env', 'env.json');
139
+ return _this3.save();
140
+ }
135
141
  });
136
142
  }
137
143
  }, {
@@ -15,6 +15,8 @@ Feel free to replace this README.md file with your own content, or keep it for r
15
15
  - [Testing and Debugging](#testing-and-debugging)
16
16
  - [GitHub Actions (CI/CD)](#github-actions-cicd)
17
17
  - [OTA](#ota)
18
+ - [Assets](#assets)
19
+ - [Environment](#environment)
18
20
  - [Support and Feedback](#support-and-feedback)
19
21
  - [Version](#version)
20
22
 
@@ -91,10 +93,30 @@ Test OTA with the 'Particle: Cloud Flash' command in Visual Studio Code or the C
91
93
 
92
94
  This firmware supports binary assets in OTA packages, allowing the inclusion of audio, images, configurations, and external microcontroller firmware. More details are [here](https://docs.particle.io/reference/device-os/api/asset-ota/asset-ota/).
93
95
 
96
+ ### Assets
97
+
98
+ To include assets in your OTA bundle, create an `assets` folder in your project root and place your files there. These can include audio files, images, configuration files, or firmware for external microcontrollers.
99
+
100
+ To enable asset OTA, uncomment the following line in `project.properties`:
101
+ ```
102
+ assetOtaDir=assets
103
+ ```
104
+
105
+ See the [Asset OTA documentation](https://docs.particle.io/reference/device-os/api/asset-ota) for more details.
106
+
107
+ ### Environment
108
+
109
+ To bundle environment variables with your firmware, create an `env.json` file in your project root. Uncomment the following line in `project.properties` to enable it:
110
+ ```
111
+ env=env.json
112
+ ```
113
+
114
+ See the [Environment documentation](https://docs.particle.io/reference/device-os/api/environment) for more details.
115
+
94
116
  ## Support and Feedback
95
117
 
96
118
  For support or feedback on this template or any Particle products, please join our [community](https://community.particle.io)!
97
119
 
98
120
  ## Version
99
121
 
100
- Template version 1.0.2
122
+ Template version 1.0.3
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": "1.0.5",
4
+ "version": "1.0.6",
5
5
  "author": "Matthew McGowan",
6
6
  "contributors": [
7
7
  {
@@ -176,9 +176,9 @@ export class ProjectInitCommand extends Command {
176
176
  });
177
177
  }
178
178
 
179
- createNotifyTemplateIfNeeded(site, fs, targetFile, templateName, data) {
179
+ async createNotifyTemplateIfNeeded(site, fs, targetFile, templateName, data) {
180
180
  // assumes the parent directory of the template exists
181
- const content = this.expandTemplate(fs, templateName, data);
181
+ const content = await this.expandTemplate(fs, templateName, data);
182
182
  return this.createNotifyFileIfNeeded(site, fs, targetFile, content);
183
183
  }
184
184
 
@@ -223,7 +223,7 @@ export class ProjectInitCommand extends Command {
223
223
  return project.save();
224
224
  }
225
225
  })
226
- .then(() => project.writeAssetOtaDir());
226
+ .then(() => project.populateProjectProperties());
227
227
  }
228
228
 
229
229
  /**
@@ -72,15 +72,21 @@ export default class ProjectProperties {
72
72
  return this.fs.writeFile(this.name(), data, 'utf8');
73
73
  }
74
74
 
75
- writeAssetOtaDir() {
76
- // // Add a commented line for assetOtaDir if it doesn't exist
77
- this.load()
75
+ populateProjectProperties() {
76
+ // Add a commented line for assetOtaDir and env if they don't exist
77
+ return this.load()
78
78
  .then(() => {
79
79
  const val = this.getField('#assetOtaDir');
80
80
  if (!val) {
81
81
  this.setField('#assetOtaDir', 'assets');
82
82
  return this.save();
83
83
  }
84
+ }).then(() => {
85
+ const val = this.getField('#env');
86
+ if (!val) {
87
+ this.setField('#env', 'env.json');
88
+ return this.save();
89
+ }
84
90
  });
85
91
  }
86
92
 
@@ -15,6 +15,8 @@ Feel free to replace this README.md file with your own content, or keep it for r
15
15
  - [Testing and Debugging](#testing-and-debugging)
16
16
  - [GitHub Actions (CI/CD)](#github-actions-cicd)
17
17
  - [OTA](#ota)
18
+ - [Assets](#assets)
19
+ - [Environment](#environment)
18
20
  - [Support and Feedback](#support-and-feedback)
19
21
  - [Version](#version)
20
22
 
@@ -91,10 +93,30 @@ Test OTA with the 'Particle: Cloud Flash' command in Visual Studio Code or the C
91
93
 
92
94
  This firmware supports binary assets in OTA packages, allowing the inclusion of audio, images, configurations, and external microcontroller firmware. More details are [here](https://docs.particle.io/reference/device-os/api/asset-ota/asset-ota/).
93
95
 
96
+ ### Assets
97
+
98
+ To include assets in your OTA bundle, create an `assets` folder in your project root and place your files there. These can include audio files, images, configuration files, or firmware for external microcontrollers.
99
+
100
+ To enable asset OTA, uncomment the following line in `project.properties`:
101
+ ```
102
+ assetOtaDir=assets
103
+ ```
104
+
105
+ See the [Asset OTA documentation](https://docs.particle.io/reference/device-os/api/asset-ota) for more details.
106
+
107
+ ### Environment
108
+
109
+ To bundle environment variables with your firmware, create an `env.json` file in your project root. Uncomment the following line in `project.properties` to enable it:
110
+ ```
111
+ env=env.json
112
+ ```
113
+
114
+ See the [Environment documentation](https://docs.particle.io/reference/device-os/api/environment) for more details.
115
+
94
116
  ## Support and Feedback
95
117
 
96
118
  For support or feedback on this template or any Particle products, please join our [community](https://community.particle.io)!
97
119
 
98
120
  ## Version
99
121
 
100
- Template version 1.0.2
122
+ Template version 1.0.3
@@ -118,6 +118,15 @@ describe('project_init', () => {
118
118
  });
119
119
  });
120
120
 
121
+ it('populates commented assetOtaDir and env fields in project.properties', () => {
122
+ return createProject({ directory:'dir6', name:'name6' })
123
+ .then(() => expectProject('dir6', { name:'name6' }))
124
+ .then((project) => {
125
+ expect(project.getField('#assetOtaDir')).to.equal('assets');
126
+ expect(project.getField('#env')).to.equal('env.json');
127
+ });
128
+ });
129
+
121
130
  // todo - preserve comments and field order
122
131
  });
123
132
  });