pkgbld 1.8.0 → 1.9.0

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/dist/get-pkg.d.ts CHANGED
@@ -1 +1,2 @@
1
- export declare function getPackage(): Promise<any[]>;
1
+ import { Json } from './types';
2
+ export declare function getPackage(): Promise<[string, Json]>;
package/dist/helpers.d.ts CHANGED
@@ -1,12 +1,16 @@
1
1
  import { getCliOptions } from './get-cli-options';
2
- export declare function getHelpers(pkg: any): {
2
+ import { OutputOptions } from 'rollup';
3
+ export declare function getHelpers(name: string): {
3
4
  getGlobalName: (anInput: string) => string;
4
5
  getExternalGlobalName: (id: string) => string;
5
6
  umdFilter: typeof umdFilter;
6
7
  };
7
8
  export declare function umdFilter(config: ReturnType<typeof getCliOptions>, filename: string): boolean;
8
- export declare function toArray<T>(object: T): (T & any[]) | T[];
9
+ export declare function toArray<T>(object: T | T[] | undefined): T[];
9
10
  export declare function isExternalInput(id: string, inputs: string | string[], currentInput: string, config: ReturnType<typeof getCliOptions>): boolean;
10
- export declare function formatInput(input: string[] | string | undefined): string | undefined;
11
- export declare function formatOutput(output: any, field: string): string | undefined;
11
+ export declare function formatInput(input: string[] | string | undefined): string;
12
+ export declare function formatOutput(output: OutputOptions | OutputOptions[] | undefined, field: 'dir' | 'format'): string;
12
13
  export declare function getTimeDiff(starting: number): string;
14
+ export declare function getDefaultExport<T extends {
15
+ default?: unknown;
16
+ }>(importedModule: T): {};
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ import '@niceties/draftlog-appender';
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
+ require('@niceties/draftlog-appender');
4
5
  var logger = require('@niceties/logger');
5
6
  var rollup = require('rollup');
6
7
  var fs = require('fs/promises');
@@ -66,10 +67,9 @@ async function getPackage() {
66
67
  return [pkgPath, JSON.parse(buffer.toString())];
67
68
  }
68
69
 
69
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
- function getHelpers(pkg) {
70
+ function getHelpers(name) {
71
71
  function getGlobalName(anInput) {
72
- return camelCase(path.join(pkg.name, path.basename(anInput, '.ts') !== 'index' ? path.basename(anInput, '.ts') : ''));
72
+ return camelCase(path.join(name, path.basename(anInput, '.ts') !== 'index' ? path.basename(anInput, '.ts') : ''));
73
73
  }
74
74
  function getExternalGlobalName(id) {
75
75
  if (path.isAbsolute(id)) {
@@ -91,6 +91,9 @@ function toArray(object) {
91
91
  if (Array.isArray(object)) {
92
92
  return object;
93
93
  }
94
+ if (object == null) {
95
+ return [];
96
+ }
94
97
  return [object];
95
98
  }
96
99
  function isExternalInput(id, inputs, currentInput, config) {
@@ -104,11 +107,15 @@ function isExternalInput(id, inputs, currentInput, config) {
104
107
  return normalizedPath !== currentInput && inputs.includes(normalizedPath);
105
108
  }
106
109
  function formatInput(input) {
107
- return Array.isArray(input) ? input.join(', ') : input;
110
+ return Array.isArray(input) ? input.join(', ') : (input !== null && input !== void 0 ? input : ''); // not sure if ?? '' needed
108
111
  }
109
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
110
112
  function formatOutput(output, field) {
111
- return Array.isArray(output) ? output.map(item => item[field]).join(', ') : output[field];
113
+ var _a;
114
+ // can we avoid it?
115
+ if (output == null) {
116
+ return '';
117
+ }
118
+ return Array.isArray(output) ? output.map(item => item[field]).join(', ') : ((_a = output[field]) !== null && _a !== void 0 ? _a : '');
112
119
  }
113
120
  function getTimeDiff(starting) {
114
121
  const now = Date.now();
@@ -203,22 +210,25 @@ function getRollupConfigs(inputs, config, helpers) {
203
210
  return configs;
204
211
  }
205
212
 
206
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
207
213
  function processPackage(pkg, config) {
208
214
  var _a;
209
215
  const input = [];
210
216
  const logger$1 = logger.createLogger();
211
- if (typeof pkg.name !== 'string') {
217
+ if (typeof pkg !== 'object' || Array.isArray(pkg)) {
218
+ logger$1.finish('expecting object on top level of package.json', 3 /* LogLevel.error */);
219
+ process.exit(-1);
220
+ }
221
+ if (typeof (pkg === null || pkg === void 0 ? void 0 : pkg.name) !== 'string') {
212
222
  logger$1.finish('expecting name to be a string in package.json', 3 /* LogLevel.error */);
213
223
  process.exit(-1);
214
224
  }
215
- if (!Array.isArray(pkg.files)) {
225
+ if (!Array.isArray(pkg === null || pkg === void 0 ? void 0 : pkg.files)) {
216
226
  pkg.files = [];
217
227
  }
218
228
  if (!pkg.files.includes(config.dir)) {
219
229
  pkg.files.push(config.dir);
220
230
  }
221
- if (typeof pkg.exports !== 'object') {
231
+ if (typeof pkg.exports !== 'object' && pkg.exports !== null) {
222
232
  pkg.exports = {};
223
233
  }
224
234
  if (pkg.exports['.'] == null) {
@@ -265,7 +275,6 @@ function processPackage(pkg, config) {
265
275
  return input;
266
276
  }
267
277
 
268
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
269
278
  async function writePackage(pkgPath, pkg) {
270
279
  await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
271
280
  }
@@ -275,7 +284,7 @@ async function execute() {
275
284
  const [pkgPath, pkg] = await getPackage();
276
285
  const config = getCliOptions();
277
286
  const inputs = processPackage(pkg, config);
278
- const helpers = getHelpers(pkg);
287
+ const helpers = getHelpers(pkg.name);
279
288
  const rollupConfigs = getRollupConfigs(inputs, config, helpers);
280
289
  for (const config of rollupConfigs) {
281
290
  const logger$1 = logger.createLogger();
@@ -1,2 +1,3 @@
1
1
  import { getCliOptions } from './get-cli-options';
2
- export declare function processPackage(pkg: any, config: ReturnType<typeof getCliOptions>): string[];
2
+ import { Json } from './types';
3
+ export declare function processPackage(pkg: Json, config: ReturnType<typeof getCliOptions>): string[];
@@ -0,0 +1,7 @@
1
+ export interface Replacer {
2
+ name: string;
3
+ used: () => void;
4
+ }
5
+ export declare type Json = null | string | number | boolean | Json[] | {
6
+ [name: string]: Json;
7
+ };
@@ -1 +1,2 @@
1
- export declare function writePackage(pkgPath: string, pkg: any): Promise<void>;
1
+ import { Json } from './types';
2
+ export declare function writePackage(pkgPath: string, pkg: Json): Promise<void>;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.8.0",
2
+ "version": "1.9.0",
3
3
  "license": "MIT",
4
4
  "name": "pkgbld",
5
5
  "author": {
@@ -35,35 +35,36 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@semantic-release/changelog": "6.0.1",
38
- "@semantic-release/commit-analyzer": "9.0.1",
38
+ "@semantic-release/commit-analyzer": "9.0.2",
39
39
  "@semantic-release/git": "10.0.1",
40
- "@semantic-release/npm": "8.0.2",
41
- "@semantic-release/release-notes-generator": "10.0.2",
42
- "@types/lodash": "4.14.178",
43
- "@typescript-eslint/eslint-plugin": "5.8.0",
44
- "@typescript-eslint/parser": "5.8.0",
40
+ "@semantic-release/npm": "9.0.1",
41
+ "@semantic-release/release-notes-generator": "10.0.3",
42
+ "@types/lodash": "4.14.186",
43
+ "@typescript-eslint/eslint-plugin": "5.41.0",
44
+ "@typescript-eslint/parser": "5.41.0",
45
45
  "conventional-changelog-angular": "5.0.13",
46
- "eslint": "8.5.0",
47
- "semantic-release": "19.0.3",
48
- "@rollup-extras/plugin-binify": "1.1.0"
46
+ "eslint": "8.26.0",
47
+ "semantic-release": "19.0.5",
48
+ "@rollup-extras/plugin-binify": "1.1.2"
49
49
  },
50
50
  "dependencies": {
51
- "@niceties/logger": "1.1.4",
51
+ "@niceties/logger": "1.1.6",
52
+ "@niceties/draftlog-appender": "1.2.5",
52
53
  "lodash": "4.17.21",
53
- "rollup": "3.1.0",
54
+ "rollup": "3.2.3",
54
55
  "rollup-plugin-terser": "7.0.2",
55
56
  "rollup-plugin-typescript2": "0.34.1",
56
57
  "rollup-plugin-preprocess": "0.0.4",
57
- "@rollup/plugin-commonjs": "23.0.0",
58
- "@rollup/plugin-node-resolve": "15.0.0",
59
- "@rollup-extras/plugin-clean": "1.3.0",
60
- "@rollup-extras/plugin-externals": "1.1.0",
58
+ "@rollup/plugin-commonjs": "23.0.2",
59
+ "@rollup/plugin-node-resolve": "15.0.1",
60
+ "@rollup-extras/plugin-clean": "1.3.2",
61
+ "@rollup-extras/plugin-externals": "1.1.3",
61
62
  "typescript": "4.8.4",
62
63
  "minimist": "1.2.7"
63
64
  },
64
65
  "overrides": {
65
66
  "rollup-plugin-terser@7.0.2": {
66
- "rollup": "3.1.0"
67
+ "rollup": "3.2.3"
67
68
  }
68
69
  }
69
70
  }