@dotpi/tools 2.10.2 → 2.11.1

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.
@@ -190,35 +190,37 @@ while ! N_PREFIX="$N_PREFIX" bash /tmp/n-install -y -a "$node_arch" "$dotpi_node
190
190
  sudo mkdir -p -- "$N_PREFIX"
191
191
  done
192
192
 
193
-
194
193
  rm -f /tmp/n-install
195
194
 
196
195
 
197
-
198
- # echo "
199
- # # dotpi: force the usage of -a for correct architecture
200
- # # (n relies on uname, which tells about the kernel, not the executables)
201
-
202
- # alias n='${environment_variables[*]} n -a ${node_arch}'
203
- # " >> "${HOME}/.bashrc" || {
204
- # error_exit $? "n alias in /root/.bashrc" $error_exit_code_node
205
- # }
206
-
207
196
  source_path="${N_PREFIX}/bin"
208
197
  destination_path="/usr/bin"
209
- executables=(
210
- corepack
211
- n
212
- node
213
- npm
214
- npx
198
+
199
+ n_path_to_symlinks() (
200
+ cd "${N_PREFIX}/bin" || {
201
+ error_exit $? "cd ${N_PREFIX}/bin" $error_exit_code_node
202
+ }
203
+
204
+ for executable in * ; do
205
+ sudo ln -s -f "${source_path}/${executable}" "${destination_path}/${executable}" || {
206
+ error_exit $? "symlink to ${destination_path}/${executable}" $error_exit_code_node
207
+ }
208
+ done
215
209
  )
216
- for executable in "${executables[@]}" ; do
217
- sudo ln -s -f "${source_path}/${executable}" "${destination_path}/${executable}" || {
218
- error_exit $? "symlink to ${destination_path}/${executable}" $error_exit_code_node
219
- }
210
+
211
+ # bootstrap: node, npm
212
+ n_path_to_symlinks
213
+
214
+ # pnpm is mandatory for node modules
215
+ for package in "${dotpi_node_install_default[@]}" "${dotpi_node_install[@]}" ; do
216
+ npm -g install "$package" || {
217
+ error_exit $? "npm install ${package}" $error_exit_code_node
218
+ }
220
219
  done
221
220
 
221
+ # update: pnpm
222
+ n_path_to_symlinks
223
+
222
224
  ############## services and modules
223
225
  error_exit_code_services=4
224
226
 
@@ -230,46 +232,22 @@ sudo loginctl enable-linger "$FIRSTUSER" || {
230
232
 
231
233
  ############# dotpi module manager
232
234
 
233
- # bootstrap-install
235
+ # # bootstrap-install
234
236
  module_name="@dotpi/module-module"
235
237
  source_path="${DOTPI_ROOT}/dist/${module_name}"
236
238
  destination_prefix="${DOTPI_ROOT}/lib"
237
239
  destination_path="${destination_prefix}/node_modules/${module_name}"
238
- {
239
- dotpi echo_info "Install ${module_name}"
240
- # minimal install in the modules directory
241
- sudo npm install --no-fund \
242
- --prefix "$destination_prefix" \
243
- --install-strategy nested \
244
- --omit dev \
245
- --save \
246
- --ignore-scripts \
247
- -- \
248
- "$source_path" || {
249
- error_exit $? "dotpi_module: error when installing '${module_name}'" $error_exit_code_services
240
+
241
+ (
242
+ cd "$destination_prefix" || {
243
+ error_exit $? "cd ${destination_prefix}" $error_exit_code_services
250
244
  }
251
245
 
252
- (
253
- echo "# Install '${module_name}' dependencies"
254
- # complete install within the module itself
255
- # be sure to install links for relative dependencies also
256
- # run postinstall script
257
-
258
- sudo rm -rf "${destination_path}/node_modules" || {
259
- error_exit $? "rm ${destination_path}/node_modules" $error_exit_code_services
260
- }
261
-
262
- sudo npm install --no-fund \
263
- --prefix "$destination_path" \
264
- --omit dev \
265
- --install-links \
266
- || {
267
- error_exit $? "dotpi_module: error when installing '${module_name}' dependencies'" $error_exit_code_services
268
- }
269
- )
270
- } || {
271
- error_exit $? "${module_name}" $error_exit_code_services
272
- }
246
+ sudo npx pnpm install --dangerously-allow-all-builds -- \
247
+ "$$module_name" || {
248
+ error_exit $? "dotpi_module: error when installing '${module_name}'" $error_exit_code_services
249
+ }
250
+ )
273
251
 
274
252
  ############## audio
275
253
  error_exit_code_audio=6
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotpi/module",
3
- "version": "1.8.3",
3
+ "version": "1.10.0",
4
4
  "description": "dotpi module management",
5
5
  "type": "module",
6
6
  "exports": {
@@ -35,17 +35,20 @@ export async function install(modules = [], {
35
35
  switch (verbose) {
36
36
  case '0':
37
37
  case 'false':
38
+ case 'none':
38
39
  case false:
39
40
  verbose = 'none';
40
41
  break;
41
42
 
42
43
  case '1':
43
44
  case 'true':
45
+ case 'short':
44
46
  case true:
45
47
  verbose = 'short';
46
48
  break;
47
49
 
48
50
  case '2':
51
+ case 'full':
49
52
  verbose = 'full';
50
53
  break;
51
54
  }
@@ -78,62 +81,29 @@ export async function install(modules = [], {
78
81
  let cwd;
79
82
 
80
83
  if(verbose === 'full') {
81
- console.log(`Getting '${moduleToInstall}' definition`);
84
+ console.log(`Installing '${moduleToInstall}'`);
82
85
  }
83
- const moduleDefinition = await definitionGet(moduleToInstall);
84
- const { name: moduleName } = moduleDefinition;
85
-
86
- // 2-steps install as npm errors when installing from git
87
- // npm error git dep preparation failed
88
-
89
- if(verbose !== 'none') {
90
- echo.info(`Installing module '${moduleToInstall}' in '${dotpiModulesDestination}'`);
91
- }
92
- cwd = dotpiModulesDestination;
93
- output = await $({
94
- cwd,
95
- env: { FORCE_COLOR: 'true' }, // do not remove colors
96
- verbose: (verbose === 'full' ? 'full' : 'none'),
97
- // minimal install in the modules directory
98
- })`
99
- npm --prefix ${cwd}
100
- install --no-fund
101
- --install-strategy nested
102
- --omit dev
103
- --save
104
- --ignore-scripts
105
- --
106
- ${moduleToInstall}
107
- `;
108
86
 
87
+ // create link first, it may be used in postinstall scripts
109
88
  await symlink(
110
89
  path.join('.', 'node_modules'),
111
90
  path.join(dotpiModulesDestination, 'dotpi_modules')
112
91
  );
113
92
 
114
- if(verbose === 'full') {
115
- echo.info(`Installing ${moduleToInstall} dependencies`)
116
- }
117
- cwd = path.resolve(dotpiModulesDestination, 'node_modules', moduleName);
118
-
119
- // perform a clean install
120
- await fs.rm(path.resolve(cwd, 'node_modules'), {
121
- recursive: true,
122
- force: true,
123
- });
93
+ const moduleDefinition = await definitionGet(moduleToInstall);
94
+ const { name: moduleName } = moduleDefinition;
124
95
 
96
+ cwd = dotpiModulesDestination;
125
97
  output = await $({
126
98
  cwd,
127
99
  env: { FORCE_COLOR: 'true' }, // do not remove colors
128
100
  verbose: (verbose === 'full' ? 'full' : 'none'),
129
- // complete install within the module itself
130
- // be sure to install links for relative dependencies also
131
- // run postinstall script
101
+ // full install with postinstall scripts for each request
132
102
  })`
133
- npm --prefix ${cwd}
134
- install --no-fund
135
- --omit dev
136
- --install-links
103
+ npx pnpm install
104
+ --dangerously-allow-all-builds
105
+ --
106
+ ${moduleToInstall}
137
107
  `;
138
108
 
139
109
  } catch (error) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotpi/module-module",
3
- "version": "1.8.3",
3
+ "version": "1.10.0",
4
4
  "description": "dotpi module management",
5
5
  "type": "module",
6
6
  "bin": "./bin/dotpi_module",
@@ -11,7 +11,7 @@
11
11
  "license": "BSD-3-clause",
12
12
  "dependencies": {
13
13
  "@dotpi/javascript": "^1.6.3",
14
- "@dotpi/module": "^1.8.3",
14
+ "@dotpi/module": "^1.10.0",
15
15
  "commander": "^12.1.0"
16
16
  }
17
17
  }
@@ -82,3 +82,8 @@ dotpi_module_install_default=(
82
82
  dotpi_module_install=()
83
83
 
84
84
  dotpi_node_version='lts'
85
+ dotpi_node_install_default=(
86
+ 'pnpm' # for @dotpi/module-module
87
+ 'yarn' # convenience
88
+ )
89
+ dotpi_node_install=()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotpi/tools",
3
- "version": "2.10.2",
3
+ "version": "2.11.1",
4
4
  "description": "Set of scripts for managing dotpi fleets of Raspberry Pi",
5
5
  "author": "Jean-Philippe Lambert",
6
6
  "contributors": [
@@ -37,7 +37,7 @@
37
37
  "license": "BSD-3-Clause",
38
38
  "dependencies": {
39
39
  "@dotpi/javascript": "^1.6.3",
40
- "@dotpi/module": "^1.8.3",
40
+ "@dotpi/module": "^1.10.0",
41
41
  "chalk": "^5.3.0",
42
42
  "commander": "^12.1.0",
43
43
  "prompts": "^2.4.2",
@@ -46,5 +46,5 @@
46
46
  "devDependencies": {
47
47
  "lerna": "^8.2.4"
48
48
  },
49
- "gitHead": "01548da878a4515021a67428b4138b2b4af1c807"
49
+ "gitHead": "512a97fa2b2c25e01ed981c76cf3c78cf5613af5"
50
50
  }