@dotpi/tools 1.4.0 → 2.3.2

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 (151) hide show
  1. package/NOTES.md +41 -1
  2. package/README.md +3 -13
  3. package/dotpi_root/bin/dotpi +1 -0
  4. package/dotpi_root/bin/dotpi_prepare_sd_card +34 -22
  5. package/dotpi_root/bin/dotpi_prepare_system +108 -68
  6. package/dotpi_root/bin/package.json +6 -0
  7. package/dotpi_root/{share/dotpi_avahi_monitor → dist/@dotpi/avahi_monitor}/dotpi_avahi_monitor.service +1 -5
  8. package/dotpi_root/dist/@dotpi/avahi_monitor/dotpi_install +21 -0
  9. package/dotpi_root/dist/@dotpi/avahi_monitor/dotpi_uninstall +17 -0
  10. package/dotpi_root/dist/@dotpi/avahi_monitor/package.json +10 -0
  11. package/dotpi_root/dist/@dotpi/javascript/bash.js +103 -0
  12. package/dotpi_root/dist/@dotpi/javascript/echo.js +13 -0
  13. package/dotpi_root/dist/@dotpi/javascript/filesystem.js +25 -0
  14. package/dotpi_root/dist/@dotpi/javascript/package.json +12 -0
  15. package/dotpi_root/dist/@dotpi/javascript/service.js +49 -0
  16. package/dotpi_root/dist/@dotpi/javascript/system.js +36 -0
  17. package/dotpi_root/dist/@dotpi/javascript/template.js +13 -0
  18. package/dotpi_root/dist/@dotpi/javascript/user.js +32 -0
  19. package/dotpi_root/dist/@dotpi/module/LICENSE +28 -0
  20. package/dotpi_root/dist/@dotpi/module/bin/dotpi_module +13 -0
  21. package/dotpi_root/dist/@dotpi/module/dotpi_install +52 -0
  22. package/dotpi_root/dist/@dotpi/module/dotpi_uninstall +50 -0
  23. package/dotpi_root/dist/@dotpi/module/package.json +22 -0
  24. package/dotpi_root/dist/@dotpi/module/src/configuration.js +43 -0
  25. package/dotpi_root/dist/@dotpi/module/src/createConfig.js +108 -0
  26. package/dotpi_root/dist/@dotpi/module/src/definition.js +7 -0
  27. package/dotpi_root/dist/@dotpi/module/src/index.js +0 -0
  28. package/dotpi_root/dist/@dotpi/module/src/install.js +145 -0
  29. package/dotpi_root/dist/@dotpi/module/src/uninstall.js +180 -0
  30. package/dotpi_root/etc/dotpi_environment_default.bash +16 -0
  31. package/dotpi_root/etc/dotpi_init.d/.gitkeep +0 -0
  32. package/dotpi_root/etc/dotpi_modules.json +8 -0
  33. package/dotpi_root/lib/package.json +6 -0
  34. package/dotpi_root/share/dotpi_audio_bluetooth/dotpi_audio_pipewire_relink +7 -6
  35. package/dotpi_root/share/dotpi_audio_bluetooth/package.json +6 -0
  36. package/dotpi_root/share/dotpi_functions/dotpi_functions_audio_device.bash +12 -26
  37. package/dotpi_root/share/dotpi_functions/dotpi_functions_configuration.bash +2 -2
  38. package/dotpi_root/share/dotpi_functions/dotpi_functions_service.bash +6 -2
  39. package/dotpi_root/share/dotpi_functions/dotpi_functions_system.bash +11 -0
  40. package/dotpi_root/share/dotpi_functions/dotpi_functions_user.bash +28 -0
  41. package/dotpi_root/share/dotpi_functions.bash +4 -4
  42. package/dotpi_root/share/dotpi_init.bash +7 -1
  43. package/dotpi_root/share/dotpi_pipewire/bin/dotpi_pipewire_relink +7 -6
  44. package/dotpi_root/share/dotpi_pipewire/dotpi_install +1 -1
  45. package/dotpi_root/share/dotpi_pipewire/package.json +9 -0
  46. package/dotpi_root/share/limits/zzz_dotpi_audio.conf +2 -6
  47. package/dotpi_root/share/wireplumber/wireplumber.conf.d/dotpi-wireplumber-config.conf +8 -0
  48. package/lerna.json +4 -0
  49. package/package.json +12 -2
  50. package/projects/led-test/.dotpi +3 -0
  51. package/projects/led-test/README.md +16 -0
  52. package/projects/led-test/dotpi_project.bash +29 -0
  53. package/projects/qsddsqsd/.dotpi +3 -0
  54. package/projects/qsddsqsd/README.md +16 -0
  55. package/projects/qsddsqsd/dotpi_project.bash +29 -0
  56. package/src/constants.js +4 -4
  57. package/src/create-project.js +124 -56
  58. package/src/templates/dotpi_project.bash +5 -7
  59. package/src/utils.js +2 -2
  60. package/test/create-project.test.js +0 -1
  61. package/PIPEWIRE.md +0 -280
  62. package/dotpi_root/bin/.editorbackup/dotpi_firstrun.bash~ +0 -149
  63. package/dotpi_root/bin/.editorbackup/dotpi_firstrun~ +0 -177
  64. package/dotpi_root/bin/.editorbackup/dotpi_prepare_sd_card.bash~ +0 -425
  65. package/dotpi_root/bin/.editorbackup/dotpi_prepare_sd_card~ +0 -620
  66. package/dotpi_root/bin/.editorbackup/dotpi_prepare_system.bash~ +0 -82
  67. package/dotpi_root/bin/.editorbackup/dotpi_prepare_system~ +0 -100
  68. package/dotpi_root/bin/.editorbackup/dotpi~ +0 -61
  69. package/dotpi_root/bin/.editorbackup/prepare_sd_card.bash~ +0 -252
  70. package/dotpi_root/etc/.editorbackup/dotpi_environment_default.bash~ +0 -49
  71. package/dotpi_root/etc/.editorbackup/dotpi_environment_instance.bash~ +0 -1
  72. package/dotpi_root/etc/.editorbackup/dotpi_environment_project.bash~ +0 -33
  73. package/dotpi_root/etc/.editorbackup/dotpi_tarignore~ +0 -4
  74. package/dotpi_root/share/.editorbackup/coucou~ +0 -1
  75. package/dotpi_root/share/.editorbackup/dotpi_environment.bash~ +0 -9
  76. package/dotpi_root/share/.editorbackup/dotpi_functions.bash~ +0 -11
  77. package/dotpi_root/share/.editorbackup/dotpi_functions_configuration.bash~ +0 -420
  78. package/dotpi_root/share/.editorbackup/dotpi_functions_connection.bash~ +0 -358
  79. package/dotpi_root/share/.editorbackup/dotpi_init.bash~ +0 -18
  80. package/dotpi_root/share/dotpi_audio_alsa/dotpi_audio_alsa.service +0 -15
  81. package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth.service~ +0 -24
  82. package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth_command~ +0 -80
  83. package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth_start_command~ +0 -26
  84. package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_audio_bluetooth_stop_command~ +0 -30
  85. package/dotpi_root/share/dotpi_audio_bluetooth/.editorbackup/dotpi_bluetooth_audio.service~ +0 -21
  86. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_audio_bluetooth.bash~ +0 -256
  87. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_audio_device.bash~ +0 -287
  88. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_bluetooth_audio.bash~ +0 -7
  89. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_configuration.bash~ +0 -428
  90. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_connection.bash~ +0 -194
  91. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_daemon.bash~ +0 -26
  92. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_soundcard.bash~ +0 -287
  93. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_soundcards.bash~ +0 -12
  94. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_system.bash~ +0 -158
  95. package/dotpi_root/share/dotpi_functions/.editorbackup/dotpi_functions_utils.bash~ +0 -152
  96. package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_bluetooth.bash~ +0 -20
  97. package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_command~ +0 -17
  98. package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_headphones.bash~ +0 -20
  99. package/dotpi_root/share/jackd/.editorbackup/dotpi_jackd_hifiberry.bash~ +0 -16
  100. package/dotpi_root/share/jackd/.editorbackup/jackd.conf~ +0 -5
  101. package/dotpi_root/share/jackd/.editorbackup/jackd.service~ +0 -15
  102. package/dotpi_root/share/jackd/.editorbackup/jackd_headphones.conf~ +0 -5
  103. package/dotpi_root/share/jackd/dotpi_jack_simple_client.service +0 -23
  104. package/dotpi_root/share/jackd/dotpi_jackd_bluetooth.bash +0 -18
  105. package/dotpi_root/share/jackd/dotpi_jackd_command +0 -26
  106. package/dotpi_root/share/jackd/dotpi_jackd_headphones.bash +0 -21
  107. package/dotpi_root/share/jackd/dotpi_jackd_hifiberry.bash +0 -17
  108. package/dotpi_root/share/jackd/jackd.service +0 -22
  109. package/dotpi_root/share/wireplumber/.editorbackup/8zzz-dotpi-wireplumber-config.lua~ +0 -1
  110. package/projects/old/dev.bak/.editorbackup/dotpi_environment_instance.bash~ +0 -1
  111. package/projects/old/dev.bak/.editorbackup/dotpi_environment_project.bash~ +0 -33
  112. package/projects/old/dev.bak/.editorbackup/wpa_supplicant.conf~ +0 -37
  113. package/projects/old/dev.bak/dotpi_environment_instance.bash +0 -1
  114. package/projects/old/dev.bak/dotpi_environment_project.bash +0 -46
  115. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/DOTPI-A114.nmconnection~ +0 -24
  116. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/DOTPI.nmconnection~ +0 -24
  117. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/Livebox-97C6_wifi_invite.nmconnection~ +0 -24
  118. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/onze.nmconnection~ +0 -22
  119. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/.editorbackup/welcome.nmconnection~ +0 -23
  120. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/DOTPI-A114.nmconnection +0 -23
  121. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/DOTPI.nmconnection +0 -23
  122. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/Livebox-97C6_wifi_invite.nmconnection +0 -24
  123. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/onze.nmconnection +0 -24
  124. package/projects/old/dev.bak/file-system/etc/NetworkManager/system-connections/welcome.nmconnection +0 -23
  125. package/projects/old/dev.bak/network/.editorbackup/DOTPI-A114.nmconnection~ +0 -24
  126. package/projects/old/dev.bak/network/.editorbackup/DOTPI.nmconnection~ +0 -24
  127. package/projects/old/dev.bak/network/.editorbackup/Livebox-97C6_wifi_invite.nmconnection~ +0 -24
  128. package/projects/old/dev.bak/network/.editorbackup/onze.nmconnection~ +0 -22
  129. package/projects/old/dev.bak/network/.editorbackup/welcome.nmconnection~ +0 -23
  130. package/projects/old/dev.bak/network/AccueilCie.nmconnection +0 -24
  131. package/projects/old/dev.bak/network/DOTPI-A114.nmconnection +0 -23
  132. package/projects/old/dev.bak/network/DOTPI.nmconnection +0 -23
  133. package/projects/old/dev.bak/network/Livebox-97C6_wifi_invite.nmconnection +0 -25
  134. package/projects/old/dev.bak/network/onze.nmconnection +0 -24
  135. package/projects/old/dev.bak/network/welcome.nmconnection +0 -23
  136. package/projects/old/dev.bak/network/wifi-access-point.nmconnection +0 -23
  137. package/projects/old/dev.bak/network/wifi-internet.nmconnection +0 -24
  138. package/projects/old/dev.bak/network/wifi-ircam-public.nmconnection +0 -24
  139. package/projects/old/dev.bak/network/wifi-local.nmconnection +0 -22
  140. package/projects/old/dev.bak/network/wifi-welcome.nmconnection +0 -24
  141. package/projects/old/dev.bak/wpa_supplicant.conf +0 -43
  142. package/projects/old/example-complete.bak/.editorbackup/dotpi_environment_instance.bash~ +0 -1
  143. package/projects/old/example-complete.bak/.editorbackup/dotpi_environment_project.bash~ +0 -26
  144. package/projects/old/example-complete.bak/.editorbackup/dotpi_project.bash~ +0 -21
  145. package/projects/old/example-complete.bak/.editorbackup/dotpi_tmp.bash~ +0 -3
  146. package/projects/old/example-complete.bak/.editorbackup/wpa_supplicant.conf~ +0 -37
  147. package/projects/old/example-complete.bak/configuration/.editorbackup/dotpi_project.bash~ +0 -21
  148. package/projects/old/example-complete.bak/configuration/dotpi_project.bash +0 -21
  149. package/projects/old/example-complete.bak/configuration/jackd/.editorbackup/dotpi_jackd.bash~ +0 -14
  150. package/projects/old/example-complete.bak/configuration/jackd/dotpi_jackd.bash +0 -14
  151. /package/dotpi_root/{share/dotpi_avahi_monitor → dist/@dotpi/avahi_monitor}/dotpi_avahi_monitor_command +0 -0
package/src/constants.js CHANGED
@@ -5,11 +5,12 @@ import { fileURLToPath } from 'node:url';
5
5
  export const LIB_ROOT = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
6
6
  export const CWD = process.cwd();
7
7
  export const HOME = os.homedir();
8
+ export const DOTPI_ROOT = path.join(LIB_ROOT, 'dotpi_root');
8
9
 
9
10
  // shell scripts that we need to execute
10
- export const PATH_DOTPI_INIT_BASH = path.join(LIB_ROOT, 'dotpi_root/share/dotpi_init.bash');
11
- export const PATH_DOTPI_PREPARE_SD_CARD_BASH = path.join(LIB_ROOT, 'dotpi_root/bin/dotpi_prepare_sd_card');
12
- // directories to read from and write to, repsectively
11
+ export const PATH_DOTPI_INIT_BASH = path.join(DOTPI_ROOT, 'share/dotpi_init.bash');
12
+ export const PATH_DOTPI_PREPARE_SD_CARD_BASH = path.join(DOTPI_ROOT, 'bin/dotpi_prepare_sd_card');
13
+ // directories to read from and write to, respectively
13
14
  export const PATH_TEMPLATE_DIRECTORY = path.join(LIB_ROOT, 'src/templates');
14
15
 
15
16
  // the files / directories that define a project
@@ -27,4 +28,3 @@ export const PATH_DOTPI_TMP_BASH = path.join(PATH_DOTPI_TMP_DIRECTORY, 'dotpi_tm
27
28
  // misc
28
29
  export const DOTPI_SSH_KEYS_PREFIX = 'id_rsa';
29
30
  export const PROJECT_NAME_REGEXP = /^[a-z0-9\-_]+$/;
30
- export const WIFI_ID_REGEXP = PROJECT_NAME_REGEXP;
@@ -6,6 +6,12 @@ import { execSync } from 'node:child_process';
6
6
  import prompts from 'prompts';
7
7
  import chalk from 'chalk';
8
8
 
9
+ import * as echo from '@dotpi/javascript/echo.js';
10
+ import * as bash from '@dotpi/javascript/bash.js';
11
+ import { install as moduleInstall } from '@dotpi/module/install.js';
12
+ import { createConfig as moduleCreateConfig } from '@dotpi/module/createConfig.js';
13
+ import { definitionGet as moduleDefinitionGet } from '@dotpi/module/definition.js';
14
+
9
15
  import {
10
16
  title,
11
17
  renderTemplate,
@@ -19,6 +25,7 @@ import {
19
25
  isDotpiProject,
20
26
  } from './utils.js';
21
27
  import {
28
+ DOTPI_ROOT,
22
29
  // path of the files inside the final project
23
30
  PATH_DOTPI_PROJECT_BASH,
24
31
  PATH_DOTPI_SECRETS_BASH,
@@ -30,7 +37,6 @@ import {
30
37
  // utilities
31
38
  DOTPI_SSH_KEYS_PREFIX,
32
39
  PROJECT_NAME_REGEXP,
33
- WIFI_ID_REGEXP,
34
40
  // this must be put in gitignore
35
41
  PATH_DOTPI_TMP_DIRECTORY,
36
42
  // where the command is executed
@@ -139,13 +145,6 @@ export async function configureProject(data, mocks = null) {
139
145
  active: 'yes',
140
146
  inactive: 'no'
141
147
  },
142
- {
143
- type: prev => prev === true ? 'text' : false,
144
- name: 'dotpiLedConfigFile',
145
- message: 'Choose the dotpi-led configuration file:',
146
- initial: './configuration/default.json',
147
- format: val => val.trim(),
148
- },
149
148
  ], { onCancel });
150
149
 
151
150
  data.files[PATH_DOTPI_PROJECT_BASH] = renderTemplate('dotpi_project.bash', {
@@ -253,23 +252,9 @@ export async function configureWiFi(data, mocks = null) {
253
252
  // https://people.freedesktop.org/~lkundrak/nm-dbus-api/nm-settings.html
254
253
  // @note - let's consider we always use wpa-psk for now
255
254
 
255
+ const computedValues = {};
256
256
  const answers = await prompts([
257
257
  {
258
- type: 'text',
259
- name: 'wifiId',
260
- message: 'Id of the WiFi connection:',
261
- validate: value => {
262
- const configPath = path.join(PATH_NETWORK_DIRECTORY, value);
263
-
264
- if (!WIFI_ID_REGEXP.test(value)) {
265
- return 'Invalid WiFi configuration id: use only lower case letters, digits, - and _';
266
- } else if (fs.existsSync(configPath)) {
267
- return `A WiFi configuration named "${value}" already exists`;
268
- }
269
-
270
- return true;
271
- },
272
- }, {
273
258
  type: 'select',
274
259
  name: 'wifiMode',
275
260
  message: 'Select WiFi mode:',
@@ -282,16 +267,48 @@ export async function configureWiFi(data, mocks = null) {
282
267
  {
283
268
  type: 'text',
284
269
  name: 'wifiSsid',
285
- message: 'Wifi SSID:',
270
+ message: 'Wifi name (SSID):',
271
+ validate: value => {
272
+
273
+ const ssidSize = new Blob([value]).size;
274
+ if (ssidSize === 0) {
275
+ return 'Please provide a non-empty SSID';
276
+ } else if(ssidSize > 32) {
277
+ return `'${value}' is too long (more than 32 bytes)`;
278
+ }
279
+
280
+ const wifiId = value.toLowerCase().replace(/[^a-z0-9\-_]/g, '_');
281
+ const configPath = path.join(PATH_NETWORK_DIRECTORY, value);
282
+
283
+ // @TODO: file is created later, this test is bypassed
284
+ if (fs.existsSync(configPath)) {
285
+ return `A WiFi configuration named "${value}" already exists`;
286
+ }
287
+
288
+ Object.assign(computedValues, { wifiId });
289
+ return true;
290
+ },
286
291
  },
287
292
  {
288
293
  type: 'text',
289
294
  name: 'wifiPsk',
290
295
  message: 'Wifi password:',
291
- validate: value => value.length < 8 ? 'A valid password must have at least 8 characters' : true,
296
+ validate: value => {
297
+ if (new Blob([value]).size < 8) {
298
+ return `'${value}' is too short (less than 8 bytes)`;
299
+ }
300
+
301
+ if (new Blob([value]).size > 63) {
302
+ return `'${value}' is too long (more than 63 bytes)`;
303
+ }
304
+
305
+ return true;
306
+ },
292
307
  },
293
308
  ], { onCancel });
294
309
 
310
+ Object.assign(answers, computedValues);
311
+
295
312
  const { wifiId, wifiMode } = answers;
296
313
  const connectionPath = path.join(PATH_NETWORK_DIRECTORY, `${wifiId}.nmconnection`);
297
314
  let connectionConfig = null;
@@ -346,7 +363,7 @@ export async function configureWiFi(data, mocks = null) {
346
363
 
347
364
 
348
365
  export async function injectUtilityFiles(data) {
349
- const { projectName } = data;
366
+ const { projectName } = data;
350
367
 
351
368
  data.files[PATH_DOTPI_FILE] = JSON.stringify({ dotpiToolsVersion: packageVersion() }, null, 2);
352
369
 
@@ -392,47 +409,98 @@ export async function persistProject(data, mocks = null) {
392
409
  title(`Project ${projectName} successfully created!`);
393
410
  }
394
411
 
412
+ export async function installModulesInProject(data) {
413
+ title('Install modules in project');
414
+
415
+ const dotpiRoot = DOTPI_ROOT;
416
+ const dotpiInit = await bash.dotpiInitSourceFileGet({ dotpiRoot });
417
+
418
+ const { projectName } = data;
419
+ const projectPath = path.join(CWD, projectName);
420
+ const projectDotpiInit = path.join(projectPath, PATH_DOTPI_PROJECT_BASH);
421
+
422
+ const modules = await bash.variableRead({
423
+ sourceFiles: [
424
+ dotpiInit,
425
+ projectDotpiInit,
426
+ ],
427
+ variable: 'dotpi_module_install',
428
+ });
429
+
430
+ await moduleInstall(modules, {
431
+ dotpiRoot,
432
+ prefix: projectPath,
433
+ verbose: 'short',
434
+ })
435
+
436
+ }
437
+
438
+ export async function generateConfigFilesInProject(data) {
439
+ title('Generate config files for modules in project');
440
+
441
+ const dotpiRoot = DOTPI_ROOT;
442
+ const { projectName } = data;
443
+ const projectPath = path.join(CWD, projectName);
444
+
445
+ await moduleCreateConfig({
446
+ dotpiRoot,
447
+ prefix: projectPath,
448
+ verbose: 'short',
449
+ })
450
+
451
+ }
452
+
395
453
  // Wrap it all
396
454
  export default async function createProject() {
397
- if (isDotpiProject()) {
398
- console.log('');
399
- console.log(chalk.yellow(`> Cannot create a dotpi project in this directory, it already contains a dotpi project`));
400
- console.log('Aborting...');
401
- process.exit(0);
402
- }
455
+ try {
456
+ if (isDotpiProject()) {
457
+ console.log('');
458
+ console.log(chalk.yellow(`> Cannot create a dotpi project in this directory, it already contains a dotpi project`));
459
+ console.log('Aborting...');
460
+ process.exit(0);
461
+ }
403
462
 
404
- const data = {
405
- projectName: null,
406
- files: {},
407
- };
463
+ const data = {
464
+ projectName: null,
465
+ files: {},
466
+ };
408
467
 
409
- await prepareProject(data);
410
- await configureProject(data);
411
- await configureSSH(data);
412
- await configureWiFi(data);
413
- await injectUtilityFiles(data);
414
- await persistProject(data);
468
+ await prepareProject(data);
469
+ await configureProject(data);
470
+ await configureSSH(data);
471
+ await configureWiFi(data);
472
+ await injectUtilityFiles(data);
473
+ await persistProject(data);
415
474
 
416
- const { configure } = await prompts({
417
- type: 'toggle',
418
- name: 'configure',
419
- message: 'Do you want to configure your local machine for this project?',
420
- initial: true,
421
- active: 'yes',
422
- inactive: 'no'
423
- }, { onCancel });
475
+ await installModulesInProject(data);
476
+ await generateConfigFilesInProject(data);
424
477
 
425
- const { projectName } = data;
478
+ title('Configure local machine for project');
426
479
 
427
- if (configure) {
428
- const projectPath = path.join(CWD, projectName);
429
- await configureHost(projectPath);
430
- }
480
+ const { configure } = await prompts({
481
+ type: 'toggle',
482
+ name: 'configure',
483
+ message: 'Do you want to configure your local machine for this project?',
484
+ initial: true,
485
+ active: 'yes',
486
+ inactive: 'no'
487
+ }, { onCancel });
431
488
 
432
- console.log(`\
489
+ const { projectName } = data;
490
+
491
+ if (configure) {
492
+ const projectPath = path.join(CWD, projectName);
493
+ await configureHost(projectPath);
494
+ }
495
+
496
+ console.log(`\
433
497
  > The dotpi project "${projectName}" is ready to be installed on some Raspberry Pi
434
498
  >
435
499
  > Next Step: plug-in a SD Card with a Raspberry Pi OS (Lite) installed and run:
436
500
  > ${chalk.yellow('dotpi-tools --install-rpi')}
437
501
  `);
502
+ } catch (error) {
503
+ echo.error(`Error while creating dotpi project: ${error.message}`, error);
504
+ process.exit(1);
505
+ }
438
506
  }
@@ -12,13 +12,11 @@ dotpi_audio_device='${d.soundCard}'
12
12
  # Node.js version
13
13
  dotpi_node_version='${d.nodeVersion}'
14
14
 
15
- # Install dotpi-manager service
16
- dotpi_manager_install='${d.installDotpiManager ? 'yes' : 'no'}'
17
-
18
- # Install dotpi-led service
19
- dotpi_led_install='${d.installDotpiLed ? 'yes' : 'no'}'
20
- ${d.installDotpiLed ? `\
21
- dotpi_led_strip_configuration='${d.dotPiLedConfigFile}'` : ``}
15
+ # User-defined dotpi modules to install
16
+ dotpi_module_install+=(
17
+ ${!d.installDotpiManager ? '# ' : ''}'@dotpi/manager'
18
+ ${!d.installDotpiLed ? '# ' : ''}'@dotpi/led'
19
+ )
22
20
 
23
21
  # Misc
24
22
  dotpi_timezone='${d.timeZone}'
package/src/utils.js CHANGED
@@ -89,7 +89,7 @@ export function isPrivateSshKey(pathname) {
89
89
  export function isWindowsWsl() {
90
90
  const buffer = execSync('uname -a', { shell: '/bin/bash' });
91
91
  const unameString = buffer.toString();
92
- return /Microsoft/.test(unameString);
92
+ return /[Mm]icrosoft/.test(unameString);
93
93
  }
94
94
 
95
95
  /**
@@ -172,4 +172,4 @@ export async function chooseProject(basePathname, mocks = null) {
172
172
  }, { onCancel });
173
173
 
174
174
  return projectPath;
175
- }
175
+ }
@@ -22,7 +22,6 @@ const configureProjectMocks = {
22
22
  keyMap: 'fr',
23
23
  installDotpiManager: true,
24
24
  installDotpiLed: false,
25
- dotpiLedConfigFile: undefined,
26
25
  };
27
26
 
28
27
  const sshMocks = {
package/PIPEWIRE.md DELETED
@@ -1,280 +0,0 @@
1
- # Pipewire
2
-
3
- - `systemctl --machine=pi@ --user`
4
- - `tmux` session
5
- - `bluez` / `bluetooth` service
6
-
7
-
8
-
9
-
10
- ## Installation
11
-
12
- See <https://wiki.debian.org/PipeWire#JACK>
13
-
14
- ```log
15
- 1 systemctl --user disable dotpi-manager.service
16
- 2 sudo dotpi apt-get install pipewire pipewire-audio pipewire-jack
17
- 6 systemctl --user enable --now wireplumber.service
18
- 7 wpctl status
19
- 8 sudo dotpi audio_bluetooth_destination_connect
20
- 9 wpctl status
21
- 10 sudo cp /usr/share/doc/pipewire/examples/ld.so.conf.d/pipewire-jack-*.conf /etc/ld.so.conf.d/
22
- 11 sudo mv /etc/ld.so.conf.d/pipewire-jack-aarch64-linux-gnu.conf /etc/ld.so.conf.d/0-pipewire-jack-aarch64-linux-gnu.conf
23
- 12 sudo ldconfig
24
- 14 sudo dotpi apt-get install jackd
25
- 15 jack_simple_client
26
- ```
27
-
28
-
29
- Version 0.3.65 in Raspberry Pi OS (Debian Bookworm).
30
-
31
- Search for `spa` or `libspa` for plugins, in particular:
32
-
33
- - [ ] jack
34
- - [ ] alsa
35
-
36
- `pipewire-media-session` is deprecated. Better use `wireplumber`.
37
-
38
- ```sh
39
- systemctl --user --now enable wireplumber.service
40
- ```
41
-
42
- <https://wiki.debian.org/PipeWire#Debian_12>
43
-
44
- > When using WirePlumber, the amount of required configuration to use PipeWire as your sound server is very minimal. In fact, the WirePlumber package recommends pipewire-pulse, so that will likely happen automatically. You'll only have to enable the ALSA and JACK layers manually, which no longer require creating an empty file in your media session's configuration directory (as that directory won't even exist when using WirePlumber), but will still require copying files from your /usr/share/doc/pipewire/examples/ directory, as described in the Debian 11 instructions.
45
-
46
- ### Realtime audio
47
-
48
- Default priority (-89) seems fine.
49
-
50
- Uses `RTKit`? Errors?
51
-
52
- At the moment rtkit is not installed
53
-
54
- ### Alsa
55
-
56
- ```sh
57
- sudo cp /usr/share/doc/pipewire/examples/alsa.conf.d/99-pipewire-default.conf /etc/alsa/conf.d/
58
- ```
59
-
60
- Be sure to set `Master` control to `100%`.
61
-
62
- Note that pipewire does not over-ride `sysdefault`, only `default``.
63
-
64
- ```sh
65
- $ aplay -L
66
- null
67
- Discard all samples (playback) or generate zero samples (capture)
68
- bluealsa
69
- Bluetooth Audio Hub
70
- pipewire
71
- PipeWire Sound Server
72
- default
73
- Default ALSA Output (currently PipeWire Media Server)
74
- hw:CARD=sndrpihifiberry,DEV=0
75
- snd_rpi_hifiberry_dacplusadcpro, HiFiBerry DAC+ADC Pro HiFi multicodec-0
76
- Direct hardware device without any conversions
77
- plughw:CARD=sndrpihifiberry,DEV=0
78
- snd_rpi_hifiberry_dacplusadcpro, HiFiBerry DAC+ADC Pro HiFi multicodec-0
79
- Hardware device with all software conversions
80
- sysdefault:CARD=sndrpihifiberry
81
- snd_rpi_hifiberry_dacplusadcpro, HiFiBerry DAC+ADC Pro HiFi multicodec-0
82
- Default Audio Device
83
- dmix:CARD=sndrpihifiberry,DEV=0
84
- snd_rpi_hifiberry_dacplusadcpro, HiFiBerry DAC+ADC Pro HiFi multicodec-0
85
- Direct sample mixing device
86
- ```
87
-
88
- ### Jackd
89
-
90
- Try to over-ride dynamic loading of jackd libray, to avoid prefixing client commands with `pw-jack`.
91
-
92
- > Install the pipewire-audio-client-libraries and libspa-0.2-jack packages, if not already installed.
93
-
94
- ```sh
95
- # Either run JACK clients using the pw-jack wrapper, or copy:
96
- sudo cp /usr/share/doc/pipewire/examples/ld.so.conf.d/pipewire-jack-*.conf /etc/ld.so.conf.d/
97
- # and run
98
- ldconfig
99
- ```
100
-
101
- ```sh
102
- pw-jack bash -c 'echo $LD_LIBRARY_PATH'
103
- # /usr/${LIB}/pipewire-0.3/jack
104
- ```
105
-
106
- Compare pipewire `/etc/pipewire/jack.conf`
107
-
108
- ```conf
109
- # global properties for all jack clients
110
- jack.properties = {
111
- node.latency = 256/48000
112
- node.rate = 1/48000
113
- node.quantum = 128/48000
114
- node.lock-quantum = true
115
- node.force-quantum = 128/48000
116
- #jack.show-monitor = true
117
- #jack.merge-monitor = true
118
- #jack.short-name = false
119
- #jack.filter-name = false
120
- #jack.filter-char = " "
121
- #
122
- # allow: Don't restrict self connect requests
123
- # fail-external: Fail self connect requests to external ports only
124
- # ignore-external: Ignore self connect requests to external ports only
125
- # fail-all: Fail all self connect requests
126
- # ignore-all: Ignore all self connect requests
127
- #jack.self-connect-mode = allow
128
- #jack.locked-process = true
129
- #jack.default-as-system = false
130
- #jack.fix-midi-events = true
131
- #jack.global-buffer-size = false
132
- session.suspend-timeout-seconds = 0 # default is 5
133
- }
134
-
135
- ```
136
-
137
- than with jackd. Cf. `/opt/dotpi/share/jackd/dotpi_jackd_hifiberry.bash`:
138
-
139
- ```bash
140
- DOTPI_JACKD_ARGUMENTS=(
141
- --realtime
142
- --realtime-priority 95
143
- -d alsa
144
- --device hw:0,0
145
- --duplex
146
- --period 128
147
- --nperiods 2
148
- --rate 48000
149
- )
150
- ```
151
-
152
- #### Latency
153
-
154
- Pipewire
155
-
156
- ```conf
157
- node.latency = 256/48000
158
- node.rate = 1/48000
159
- node.quantum = 256/48000
160
- node.lock-quantum = true
161
- node.force-quantum = 256/48000
162
- ```
163
-
164
- ```
165
- 670.440 frames 13.968 ms total roundtrip latency
166
- extra loopback latency: 158 frames
167
- use 79 for the backend arguments -I and -O
168
- ```
169
-
170
-
171
- ```conf
172
- node.latency = 256/48000
173
- node.rate = 1/48000
174
- node.quantum = 128/48000
175
- node.lock-quantum = true
176
- node.force-quantum = 128/48000
177
- ```
178
-
179
- ```
180
- 671.155 frames 13.982 ms total roundtrip latency
181
- extra loopback latency: 159 frames
182
- use 79 for the backend arguments -I and -O
183
- ```
184
-
185
- ```conf
186
- node.latency = 128/48000
187
- node.rate = 1/48000
188
- node.quantum = 128/48000
189
- node.lock-quantum = true
190
- node.force-quantum = 128/48000
191
- ```
192
-
193
- ```
194
- 392.311 frames 8.173 ms total roundtrip latency
195
- extra loopback latency: 136 frames
196
- use 68 for the backend arguments -I and -O
197
- ```
198
-
199
-
200
-
201
- Jackd:
202
- ```
203
- 434.351 frames 9.049 ms total roundtrip latency
204
- extra loopback latency: 50 frames
205
- use 25 for the backend arguments -I and -O
206
- ```
207
-
208
- ### Bluetooth
209
-
210
- > At minimum, you will need to install the libspa-0.2-bluetooth package, remove the pulseaudio-module-bluetooth package, and then either reboot your computer or restart the PipeWire services, otherwise device connections will fail with "Protocol not available".
211
-
212
- > PipeWire will attempt to choose the best possible codec by default. You can override this, and tweak many other related settings, in the /etc/pipewire/media-session.d/bluez-monitor.conf file. You can edit this directly, or store local per-user changes by copying the file to ~/.config/pipewire/media-session.d/bluez-monitor.conf and editing that instead.
213
-
214
- ### Run with session
215
-
216
- Need a user session? No, use lingering
217
-
218
- ```sh
219
- sudo loginctl enable-linger pi
220
- ```
221
-
222
- ```sh
223
- systemctl --user status pipewire
224
- ```
225
-
226
- Install `wireplumber` instead of `pipewire-media-session`
227
-
228
- ## Start with `pw-jack`
229
-
230
- Is it possible to bypass that with the `ld` over-ride?
231
-
232
- ```sh
233
- sudo cp /usr/share/doc/pipewire/examples/ld.so.conf.d/pipewire-jack-*.conf /etc/ld.so.conf.d/
234
- ```
235
-
236
- ## Rust WebAudio
237
-
238
- - [ ] dotpi-manager: 2 clients (2x jack connections) on startup.
239
- - [ ] bad Alsa device selection (should be default, not hw:0)
240
-
241
- ```log
242
- Jan 30 17:52:22 dotpi-dev-076 systemd[1]: Starting dotpi-manager.service - dotpi manager...
243
- Jan 30 17:52:22 dotpi-dev-076 systemd[1]: Started dotpi-manager.service - dotpi manager.
244
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: Failed to open client because of error: ClientError(FAILURE | SERVER_FAILED)
245
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: Failed to open client because of error: ClientError(FAILURE | SERVER_FAILED)
246
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: thread '<unnamed>' panicked at /home/pi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/web-audio-api-0.38.0/src/io/cpal.rs:150:14:
247
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: error while querying config: BackendSpecific { err: BackendSpecificError { description: "ALSA function 'snd_pcm_open' failed with error 'EHOSTDOWN: Host is down'" } }
248
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: stack backtrace:
249
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 0: 0x7f8ec99c80 - <unknown>
250
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 1: 0x7f8eb68b2c - <unknown>
251
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 2: 0x7f8ec75d1c - <unknown>
252
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 3: 0x7f8ec9afc8 - <unknown>
253
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 4: 0x7f8ec9abec - <unknown>
254
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 5: 0x7f8ec9bae4 - <unknown>
255
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 6: 0x7f8ec9b630 - <unknown>
256
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 7: 0x7f8ec9b59c - <unknown>
257
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 8: 0x7f8ec9b590 - <unknown>
258
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 9: 0x7f8eb4a508 - <unknown>
259
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 10: 0x7f8eb4a870 - <unknown>
260
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 11: 0x7f8ed438fc - <unknown>
261
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 12: 0x7f8eb61e80 - <unknown>
262
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 13: 0x7f8ebd5d0c - <unknown>
263
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 14: 0xc2a6e4 - _ZN6v8impl12_GLOBAL__N_123FunctionCallbackWrapper6InvokeERKN2v820FunctionCallbackInfoINS2_5ValueEEE
264
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 15: 0xeefaf8 - _ZN2v88internal25FunctionCallbackArguments4CallENS0_15CallHandlerInfoE
265
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 16: 0xef006c - _ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb1EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEENS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EEPmi
266
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 17: 0xef065c - _ZN2v88internal21Builtin_HandleApiCallEiPmPNS0_7IsolateE
267
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: 18: 0x186d964 - Builtins_CEntry_Return1_ArgvOnStack_BuiltinExit
268
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: /opt/dotpi/share/dotpi-manager/runtime/node_modules/node-web-audio-api/monkey-patch.js:44
269
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: super(options);
270
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: ^
271
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: Error: error while querying config: BackendSpecific { err: BackendSpecificError { description: "ALSA function 'snd_pcm_open' failed with error 'EHOSTDOWN: Host is down'" } }
272
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: at new AudioContext (/opt/dotpi/share/dotpi-manager/runtime/node_modules/node-web-audio-api/monkey-patch.js:44:7)
273
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: at file:///opt/dotpi/share/dotpi-manager/runtime/src/clients/thing/controllers/test-audio.js:3:22
274
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
275
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: at ModuleLoader.import (node:internal/modules/esm/loader:329:24)
276
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: at loadESM (node:internal/process/esm_loader:28:7)
277
- Jan 30 17:52:22 dotpi-dev-076 pw-jack[2765]: at handleMainPromise (node:internal/modules/run_main:113:12)
278
- Jan 30 17:52:22 dotpi-dev-076 systemd[1]: dotpi-manager.service: Main process exited, code=exited, status=1/FAILURE
279
- Jan 30 17:52:22 dotpi-dev-076 systemd[1]: dotpi-manager.service: Failed with result 'exit-code'.
280
- ```