deboa 1.1.1 → 1.1.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.
@@ -18,6 +18,7 @@ const _writeFileFromLines = require("../utils/writeFileFromLines");
18
18
  const _deboaFromFile = require("./DeboaFromFile");
19
19
  const _stream = require("stream");
20
20
  const _addTarEntries = require("../utils/addTarEntries");
21
+ const _changeOwnerToRoot = require("../utils/changeOwnerToRoot");
21
22
  function _interopRequireDefault(obj) {
22
23
  return obj && obj.__esModule ? obj : {
23
24
  default: obj
@@ -272,13 +273,7 @@ function _interopRequireWildcard(obj, nodeInterop) {
272
273
  const controlFileWriteStream = _fs.default.createWriteStream(controlFileLocation);
273
274
  _tarFs.default.pack(this.#dataFolderDestination, {
274
275
  map: (header)=>{
275
- // Why: while undocumented, this header accepts options for the header passed to tar-stream's pack function
276
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
277
- // @ts-ignore
278
- header.gname = 'root';
279
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
280
- // @ts-ignore
281
- header.uname = 'root';
276
+ header = (0, _changeOwnerToRoot.changeOwnerToRoot)(header);
282
277
  // sensible defaults for Windows users
283
278
  if (process.platform === 'win32') {
284
279
  const defaultFilePermission = parseInt('0644', 8);
@@ -314,6 +309,7 @@ function _interopRequireWildcard(obj, nodeInterop) {
314
309
  }).pipe(dataFileCompressor).pipe(dataFileWriteStream);
315
310
  _tarFs.default.pack(this.#controlFolderDestination, {
316
311
  map: (header)=>{
312
+ header = (0, _changeOwnerToRoot.changeOwnerToRoot)(header);
317
313
  const maintainerScripts = [
318
314
  'postinst',
319
315
  'postrm',
@@ -0,0 +1,6 @@
1
+ import type { IDeboa } from '../types';
2
+ /**
3
+ * Ensures all files/directories in the .tar archive are owned by root,
4
+ * not by the current user when running on Unix or by a invalid user on Windows.
5
+ */
6
+ export declare const changeOwnerToRoot: Exclude<IDeboa['modifyTarHeader'], string>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "changeOwnerToRoot", {
6
+ enumerable: true,
7
+ get: ()=>changeOwnerToRoot
8
+ });
9
+ const changeOwnerToRoot = (header)=>{
10
+ header.gname = 'root';
11
+ header.uname = 'root';
12
+ header.gid = 0;
13
+ header.uid = 0;
14
+ return header;
15
+ };
@@ -10,6 +10,7 @@ import { writeFileFromLines } from '../utils/writeFileFromLines';
10
10
  import { DeboaFromFile } from './DeboaFromFile';
11
11
  import { PassThrough as PassThroughStream } from 'stream';
12
12
  import { addTarEntries } from '../utils/addTarEntries';
13
+ import { changeOwnerToRoot } from '../utils/changeOwnerToRoot';
13
14
  /**
14
15
  * @return IDeboa
15
16
  */ class Deboa {
@@ -220,13 +221,7 @@ import { addTarEntries } from '../utils/addTarEntries';
220
221
  const controlFileWriteStream = fs.createWriteStream(controlFileLocation);
221
222
  tar.pack(this.#dataFolderDestination, {
222
223
  map: (header)=>{
223
- // Why: while undocumented, this header accepts options for the header passed to tar-stream's pack function
224
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
225
- // @ts-ignore
226
- header.gname = 'root';
227
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
228
- // @ts-ignore
229
- header.uname = 'root';
224
+ header = changeOwnerToRoot(header);
230
225
  // sensible defaults for Windows users
231
226
  if (process.platform === 'win32') {
232
227
  const defaultFilePermission = parseInt('0644', 8);
@@ -262,6 +257,7 @@ import { addTarEntries } from '../utils/addTarEntries';
262
257
  }).pipe(dataFileCompressor).pipe(dataFileWriteStream);
263
258
  tar.pack(this.#controlFolderDestination, {
264
259
  map: (header)=>{
260
+ header = changeOwnerToRoot(header);
265
261
  const maintainerScripts = [
266
262
  'postinst',
267
263
  'postrm',
@@ -0,0 +1,6 @@
1
+ import type { IDeboa } from '../types';
2
+ /**
3
+ * Ensures all files/directories in the .tar archive are owned by root,
4
+ * not by the current user when running on Unix or by a invalid user on Windows.
5
+ */
6
+ export declare const changeOwnerToRoot: Exclude<IDeboa['modifyTarHeader'], string>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Ensures all files/directories in the .tar archive are owned by root,
3
+ * not by the current user when running on Unix or by a invalid user on Windows.
4
+ */ export const changeOwnerToRoot = (header)=>{
5
+ header.gname = 'root';
6
+ header.uname = 'root';
7
+ header.gid = 0;
8
+ header.uid = 0;
9
+ return header;
10
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "deboa",
3
3
  "author": "Erik Moura <erikian@erikian.dev>",
4
- "version": "1.1.1",
4
+ "version": "1.1.2",
5
5
  "description": "Create .deb files in any platform with Node.js",
6
6
  "main": "./dist/cjs/index.js",
7
7
  "module": "./dist/esm/index.js",
@@ -16,6 +16,12 @@
16
16
  "require": "./dist/cjs/index.js"
17
17
  }
18
18
  },
19
+ "files": [
20
+ "dist",
21
+ "LICENSE",
22
+ "README.md",
23
+ "package.json"
24
+ ],
19
25
  "scripts": {
20
26
  "build": "rimraf dist && concurrently \"yarn:build:*\"",
21
27
  "build:esm": "swc --config-file .swcrc-esm ./src --out-dir dist/esm && tsc -p tsconfig.json",