@hurshb50/setup-ubuntu 1.0.0 → 1.0.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.
package/README.md CHANGED
@@ -7,9 +7,11 @@ Sets up a fresh Ubuntu machine with tools, configuration, and dotfiles.
7
7
  ```bash
8
8
  sudo apt update && sudo apt install -y curl ca-certificates
9
9
  curl -fsSL https://vite.plus | bash
10
- vpx @hurshb50/setup-ubuntu
10
+ VP_PACKAGE_MANAGER=npm@12 vpx @hurshb50/setup-ubuntu
11
11
  ```
12
12
 
13
+ Vite+ defaults to pnpm, which can hold back freshly published releases. The setup pins npm globally, so later commands need no prefix.
14
+
13
15
  ## After Installation
14
16
 
15
17
  Open a new terminal, then:
@@ -29,6 +29,10 @@ function path() {
29
29
  export PATH="$HOME/.local/bin:$PATH"
30
30
  }
31
31
 
32
+ function package_manager() {
33
+ export VP_PACKAGE_MANAGER="npm@12"
34
+ }
35
+
32
36
  function setup_history() {
33
37
  shopt -s histappend
34
38
  shopt -s checkwinsize
@@ -131,6 +135,7 @@ function run() {
131
135
  fi
132
136
 
133
137
  path
138
+ package_manager
134
139
  load_auto_suggestion
135
140
  setup_history
136
141
  completion
@@ -10,7 +10,7 @@ import fs from "fs/promises";
10
10
  import { execa } from "execa";
11
11
  //#region package.json
12
12
  var name = "@hurshb50/setup-ubuntu";
13
- var version = "0.0.3";
13
+ var version = "1.0.1";
14
14
  //#endregion
15
15
  //#region source/modules/logger/logger.ts
16
16
  var Logger = class Logger {
@@ -184,6 +184,19 @@ var DependencyManager = class {
184
184
  }
185
185
  }))).every((installation) => installation === true);
186
186
  }
187
+ async authenticate() {
188
+ if (await this.isAuthenticated()) return;
189
+ process.stdout.write("Administrator access is required to install packages. You may be prompted for your password.\n");
190
+ try {
191
+ await execa("sudo", ["--validate"], {
192
+ stdin: "inherit",
193
+ stdout: "inherit",
194
+ stderr: "inherit"
195
+ });
196
+ } catch (error) {
197
+ throw new Error("Administrator access was not granted. Run 'sudo --validate' and then run this tool again.", { cause: error });
198
+ }
199
+ }
187
200
  async install(dependencies, task) {
188
201
  await this.enqueue([
189
202
  "install",
@@ -195,8 +208,17 @@ var DependencyManager = class {
195
208
  async update(task) {
196
209
  await this.enqueue(["update"], task);
197
210
  }
211
+ async isAuthenticated() {
212
+ try {
213
+ await execa("sudo", ["--non-interactive", "--validate"], { stdin: "ignore" });
214
+ return true;
215
+ } catch {
216
+ return false;
217
+ }
218
+ }
198
219
  enqueue(managerArguments, task) {
199
220
  const operation = this.queue.then(async () => {
221
+ if (!await this.isAuthenticated()) throw new Error("Administrator access is no longer available for apt-get. Run 'sudo --validate' and then run this tool again.");
200
222
  const subprocess = execa("sudo", [
201
223
  "env",
202
224
  ...["DEBIAN_FRONTEND=noninteractive", "NEEDRESTART_SUSPEND=1"],
@@ -204,13 +226,15 @@ var DependencyManager = class {
204
226
  ...managerArguments
205
227
  ], { stdin: "ignore" });
206
228
  let partial = "";
207
- subprocess.stdout?.on("data", (chunk) => {
229
+ const track = (chunk) => {
208
230
  partial += chunk.toString();
209
231
  const lines = partial.split(/\r\n|\r|\n/);
210
232
  partial = lines.pop() ?? "";
211
233
  const line = lines.at(-1)?.trim();
212
234
  if (line) task.continue(line);
213
- });
235
+ };
236
+ subprocess.stdout?.on("data", track);
237
+ subprocess.stderr?.on("data", track);
214
238
  await subprocess;
215
239
  });
216
240
  this.queue = operation.catch(() => {});
@@ -604,6 +628,7 @@ var Wallpapers = class {
604
628
  program.name(name).version(version).description("Sets up a fresh Ubuntu machine with a standard set of tools, configuration, and dotfiles.").action(async () => {
605
629
  const logger = new Logger();
606
630
  const dependencyManager = new DependencyManager();
631
+ await dependencyManager.authenticate();
607
632
  logger.start();
608
633
  const packages = [
609
634
  new AgentRules(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hurshb50/setup-ubuntu",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "distribution"