nodecommons-esm-app 0.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.
@@ -0,0 +1,19 @@
1
+ import { ICommonsStateful, ECommonsRunState } from 'tscommons-esm-async';
2
+ import { CommonsArgs } from 'nodecommons-esm-cli';
3
+ export declare function assertSet(property: unknown, name: string): asserts property;
4
+ export declare class CommonsBareApp implements ICommonsStateful {
5
+ private args;
6
+ private state;
7
+ private aborted;
8
+ private error;
9
+ constructor();
10
+ protected getArgs(): CommonsArgs;
11
+ isAborted(): boolean;
12
+ abort(): void;
13
+ getState(): ECommonsRunState;
14
+ getError(): Error | undefined;
15
+ protected init(): Promise<void>;
16
+ protected run(): Promise<void>;
17
+ protected shutdown(): Promise<void>;
18
+ start(): Promise<void>;
19
+ }
@@ -0,0 +1,64 @@
1
+ import { ECommonsRunState } from 'tscommons-esm-async';
2
+ import { CommonsArgs, commonsOutputAlert, commonsOutputDebug, commonsOutputError } from 'nodecommons-esm-cli';
3
+ import { commonsGracefulAbortAddCallback, commonsGracefulAbortRemoveCallback } from 'nodecommons-esm-process';
4
+ export function assertSet(property, name) {
5
+ if (!property)
6
+ throw new Error(`ASSERTION FAIL: ${name} has not been set.`);
7
+ }
8
+ export class CommonsBareApp {
9
+ args;
10
+ state;
11
+ aborted = false;
12
+ error;
13
+ constructor() {
14
+ this.args = new CommonsArgs();
15
+ this.state = ECommonsRunState.PRE;
16
+ }
17
+ getArgs() {
18
+ return this.args;
19
+ }
20
+ isAborted() {
21
+ return this.aborted;
22
+ }
23
+ abort() {
24
+ this.aborted = true;
25
+ }
26
+ getState() {
27
+ return this.state;
28
+ }
29
+ getError() {
30
+ return this.error;
31
+ }
32
+ async init() {
33
+ const gracefulAbortId = commonsGracefulAbortAddCallback(() => {
34
+ commonsGracefulAbortRemoveCallback(gracefulAbortId);
35
+ commonsOutputAlert('SIGINT abort flag is set. Aborting application.');
36
+ this.abort();
37
+ });
38
+ }
39
+ async run() {
40
+ // to be overridden if desired
41
+ }
42
+ async shutdown() {
43
+ commonsOutputDebug('Shutting down CommonsAppBare');
44
+ // to be overridden if desired
45
+ }
46
+ async start() {
47
+ try {
48
+ await this.init();
49
+ this.state = ECommonsRunState.RUNNING;
50
+ await this.run();
51
+ if (this.isAborted())
52
+ this.state = ECommonsRunState.ABORTED;
53
+ else
54
+ this.state = ECommonsRunState.COMPLETED;
55
+ await this.shutdown();
56
+ }
57
+ catch (e) {
58
+ this.state = ECommonsRunState.ERROR;
59
+ this.error = e;
60
+ commonsOutputError(`Application error: ${this.error.message}`);
61
+ }
62
+ }
63
+ }
64
+ //# sourceMappingURL=commons-bare.app.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commons-bare.app.mjs","sourceRoot":"","sources":["../../src/apps/commons-bare.app.mts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9G,OAAO,EAAE,+BAA+B,EAAE,kCAAkC,EAAE,MAAM,yBAAyB,CAAC;AAE9G,MAAM,UAAU,SAAS,CACvB,QAAiB,EACjB,IAAY;IAEb,IAAI,CAAC,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,oBAAoB,CAAC,CAAC;AAC7E,CAAC;AAED,MAAM,OAAO,cAAc;IAClB,IAAI,CAAc;IAElB,KAAK,CAAmB;IACxB,OAAO,GAAY,KAAK,CAAC;IACzB,KAAK,CAAkB;IAE/B;QACC,IAAI,CAAC,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC;QAE9B,IAAI,CAAC,KAAK,GAAG,gBAAgB,CAAC,GAAG,CAAC;IACnC,CAAC;IAES,OAAO;QAChB,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IAEM,SAAS;QACf,OAAO,IAAI,CAAC,O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import { TEncodedObject, TPropertyObject } from 'tscommons-esm-core';
2
+ import { CommonsConfig } from 'tscommons-esm-config';
3
+ import { CommonsArgs } from 'nodecommons-esm-cli';
4
+ import { CommonsConfigFile } from 'nodecommons-esm-config';
5
+ import { ICommonsPackageJson } from '../interfaces/icommons-package-json.mjs';
6
+ import { CommonsBareApp } from './commons-bare.app.mjs';
7
+ export declare class CommonsApp extends CommonsBareApp {
8
+ private name;
9
+ protected configFile?: string | undefined;
10
+ private configPath?;
11
+ static getConfigPaths(name?: string, args?: CommonsArgs, argsKey?: string, envVar?: string, configFile?: string): string[];
12
+ protected config: CommonsConfig | CommonsConfigFile;
13
+ private configPaths;
14
+ constructor(name: string, configFile?: string | undefined, configPath?: string | undefined, // NB, a direct path, not the name of the args parameter
15
+ envVar?: string, argsKey?: string, allowNoConfig?: boolean);
16
+ getConfigArea(area: string, optional?: boolean): TPropertyObject;
17
+ setConfigArea<T extends TEncodedObject>(area: string, config: T): void;
18
+ protected locateConfigFile(file: string): string;
19
+ loadRawJsonConfigFile(file: string): unknown;
20
+ loadConfigFile(file: string): CommonsConfigFile;
21
+ saveConfig(): void;
22
+ getPackageJson(): ICommonsPackageJson | undefined;
23
+ installSystemd(command: string, description: string, group?: string, autoJoinGroup?: boolean, restart?: string, restartSec?: number, autoEnable?: boolean, autoStart?: boolean, systemdServiceName?: string): void;
24
+ uninstallSystemd(group?: string, systemdServiceName?: string): void;
25
+ autoSystemd(command: string, description: string, group?: string, autoJoinGroup?: boolean, restart?: string, restartSec?: number, autoEnable?: boolean, autoStart?: boolean, systemdServiceName?: string): void | never;
26
+ }
@@ -0,0 +1,243 @@
1
+ import * as os from 'os';
2
+ import * as nodePath from 'path';
3
+ import { commonsStringKebabCase, commonsStringSnakeCase, commonsTypeIsObject } from 'tscommons-esm-core';
4
+ import { CommonsConfig } from 'tscommons-esm-config';
5
+ import { commonsEnvGetStringOrUndefined, commonsOutputAlert, commonsOutputDebug, commonsOutputDoing, commonsOutputError, commonsOutputFail, commonsOutputSuccess } from 'nodecommons-esm-cli';
6
+ import { commonsFileCwdRelativeOrAbsolutePath, commonsFileIsDirectory, commonsFileIsFile, commonsFileReadJsonFile, commonsFileRootRelativePath } from 'nodecommons-esm-file';
7
+ import { CommonsConfigFile } from 'nodecommons-esm-config';
8
+ import { commonsSystemdInstall, commonsSystemdUninstall } from 'nodecommons-esm-process';
9
+ import { isICommonsPackageJson } from '../interfaces/icommons-package-json.mjs';
10
+ import { CommonsBareApp } from './commons-bare.app.mjs';
11
+ // we're doing this in here rather than in a nodecommons-process or similar, as it's very bespoke to this code
12
+ var ESimplifiedPlatform;
13
+ (function (ESimplifiedPlatform) {
14
+ ESimplifiedPlatform["POSIX"] = "posix";
15
+ ESimplifiedPlatform["WIN32"] = "win32";
16
+ })(ESimplifiedPlatform || (ESimplifiedPlatform = {}));
17
+ // we're doing this in here rather than in a nodecommons-process or similar, as it's very bespoke to this code
18
+ function simplifiedPlatform() {
19
+ switch (os.platform()) {
20
+ case 'aix':
21
+ case 'android':
22
+ case 'darwin':
23
+ case 'freebsd':
24
+ case 'linux':
25
+ case 'netbsd':
26
+ case 'openbsd':
27
+ case 'sunos':
28
+ return ESimplifiedPlatform.POSIX;
29
+ case 'win32':
30
+ case 'cygwin':
31
+ return ESimplifiedPlatform.WIN32;
32
+ default:
33
+ throw new Error('OS platform not supported for CommonsFile');
34
+ }
35
+ }
36
+ export class CommonsApp extends CommonsBareApp {
37
+ name;
38
+ configFile;
39
+ configPath;
40
+ static getConfigPaths(name, args, argsKey = 'config-path', envVar, configFile) {
41
+ const attempts = [];
42
+ if (args) {
43
+ const path = args.getFirstValueOrUndefined(argsKey);
44
+ if (path !== undefined)
45
+ attempts.push(path);
46
+ }
47
+ if (!envVar && name) {
48
+ envVar = `${commonsStringSnakeCase(name).toUpperCase()}_CONFIG`;
49
+ commonsOutputDebug(`Calculated environment variable for config is ${envVar}`);
50
+ }
51
+ if (envVar) {
52
+ const env = commonsEnvGetStringOrUndefined(envVar);
53
+ if (env !== undefined)
54
+ attempts.push(env);
55
+ }
56
+ const relative = commonsFileCwdRelativeOrAbsolutePath('config');
57
+ if (commonsFileIsDirectory(relative))
58
+ attempts.push(relative);
59
+ if (name) {
60
+ switch (simplifiedPlatform()) {
61
+ case ESimplifiedPlatform.POSIX: {
62
+ const etc = commonsFileCwdRelativeOrAbsolutePath(`/etc/${name}`);
63
+ commonsOutputDebug(`Calculated /etc path for config is ${etc}`);
64
+ if (commonsFileIsDirectory(etc))
65
+ attempts.push(etc);
66
+ const home = nodePath.join(os.homedir(), `.${name}`);
67
+ commonsOutputDebug(`Calculated $HOME path for config is ${home}`);
68
+ if (commonsFileIsDirectory(home))
69
+ attempts.push(home);
70
+ break;
71
+ }
72
+ case ESimplifiedPlatform.WIN32:
73
+ // not implemented for win32 yet
74
+ break;
75
+ }
76
+ }
77
+ if (configFile) {
78
+ // derive the configPath from the configFile absolute path
79
+ const parts = configFile.split(nodePath.sep);
80
+ parts.pop();
81
+ const result = parts.join(nodePath.sep);
82
+ if (commonsFileIsDirectory(result))
83
+ attempts.push(result);
84
+ }
85
+ if (name) {
86
+ const localNodeModulesConfig = commonsFileRootRelativePath(nodePath.join('node_modules', name, 'config'));
87
+ commonsOutputDebug(`Calculated cwd node_modules path for config is ${localNodeModulesConfig}`);
88
+ if (commonsFileIsDirectory(localNodeModulesConfig))
89
+ attempts.push(localNodeModulesConfig);
90
+ const globalNodeModulesConfig = commonsFileRootRelativePath('config');
91
+ commonsOutputDebug(`Calculated global node_modules path for config is ${globalNodeModulesConfig}`);
92
+ if (commonsFileIsDirectory(globalNodeModulesConfig))
93
+ attempts.push(globalNodeModulesConfig);
94
+ }
95
+ commonsOutputDebug(`Searching for config in paths: ${attempts.join('; ')}`);
96
+ return attempts;
97
+ }
98
+ config;
99
+ configPaths;
100
+ constructor(name, configFile, configPath, // NB, a direct path, not the name of the args parameter
101
+ envVar, argsKey = 'config-path', allowNoConfig = false) {
102
+ super();
103
+ this.name = name;
104
+ this.configFile = configFile;
105
+ this.configPath = configPath;
106
+ const c = this.getArgs().getFirstValueOrUndefined('config');
107
+ if (c)
108
+ this.configFile = c;
109
+ if (!this.configFile) {
110
+ this.configFile = `${commonsStringKebabCase(this.name)}.json`;
111
+ }
112
+ if (this.configPath) {
113
+ this.configPaths = [this.configPath];
114
+ }
115
+ else {
116
+ this.configPaths = CommonsApp.getConfigPaths(this.name, this.getArgs(), argsKey, envVar, this.configFile);
117
+ if (this.configPaths.length === 0 && !allowNoConfig)
118
+ throw new Error('Unable to derive config path');
119
+ }
120
+ if (this.configPaths.length === 0 && allowNoConfig) {
121
+ this.config = new CommonsConfig({});
122
+ }
123
+ else {
124
+ this.config = this.loadConfigFile(this.configFile);
125
+ }
126
+ }
127
+ getConfigArea(area, optional = false) {
128
+ const result = this.config.getObject(area, optional ? {} : undefined);
129
+ if (!commonsTypeIsObject(result))
130
+ throw new Error('Invalid config area');
131
+ return result;
132
+ }
133
+ setConfigArea(area, config) {
134
+ this.config.setObject(area, config);
135
+ }
136
+ locateConfigFile(file) {
137
+ const asAbsolute = commonsFileCwdRelativeOrAbsolutePath(file);
138
+ if (file === asAbsolute)
139
+ return file;
140
+ for (const path of this.configPaths) {
141
+ //const p: string = /^\//.test(path) ? path : commonsFileRootRelativePath(path);
142
+ const attempt = nodePath.join(path, file);
143
+ commonsOutputDebug(`Looking for config file at ${attempt}`);
144
+ if (commonsFileIsFile(attempt)) {
145
+ commonsOutputDebug('Found config file.');
146
+ return attempt;
147
+ }
148
+ }
149
+ throw new Error(`Unable to locate config file ${file} at any config path location`);
150
+ }
151
+ loadRawJsonConfigFile(file) {
152
+ const location = this.locateConfigFile(file);
153
+ return commonsFileReadJsonFile(location);
154
+ }
155
+ loadConfigFile(file) {
156
+ const location = this.locateConfigFile(file);
157
+ return new CommonsConfigFile(location);
158
+ }
159
+ saveConfig() {
160
+ if (!(this.config instanceof CommonsConfigFile))
161
+ throw new Error('Cannot save to a non-file based config');
162
+ this.config.save();
163
+ }
164
+ getPackageJson() {
165
+ const attempts = [];
166
+ const relative = commonsFileCwdRelativeOrAbsolutePath('package.json');
167
+ if (commonsFileIsFile(relative))
168
+ attempts.push(relative);
169
+ const localNodeModulesPackage = commonsFileRootRelativePath(nodePath.join('node_modules', this.name, 'package.json'));
170
+ commonsOutputDebug(`Calculated cwd node_modules path for package.json is ${localNodeModulesPackage}`);
171
+ if (commonsFileIsFile(localNodeModulesPackage))
172
+ attempts.push(localNodeModulesPackage);
173
+ const globalNodeModulesPackage = commonsFileRootRelativePath('package.json');
174
+ commonsOutputDebug(`Calculated global node_modules path for package.json is ${globalNodeModulesPackage}`);
175
+ if (commonsFileIsFile(globalNodeModulesPackage))
176
+ attempts.push(globalNodeModulesPackage);
177
+ if (attempts.length === 0) {
178
+ commonsOutputAlert('package.json could not be located');
179
+ return undefined;
180
+ }
181
+ const first = attempts.shift();
182
+ commonsOutputDebug(`Found package.json in path: ${first}`);
183
+ const attempt = commonsFileReadJsonFile(first);
184
+ if (!isICommonsPackageJson(attempt))
185
+ return undefined;
186
+ return attempt;
187
+ }
188
+ installSystemd(command, description, group, autoJoinGroup = false, restart = 'always', restartSec = 5, autoEnable = true, autoStart = false, systemdServiceName) {
189
+ switch (simplifiedPlatform()) {
190
+ case ESimplifiedPlatform.POSIX: {
191
+ const etcConfig = new CommonsConfigFile(`/etc/${this.name}/${this.name}.json`);
192
+ etcConfig.cloneConfig(this.config);
193
+ commonsSystemdInstall(systemdServiceName === undefined ? this.name : systemdServiceName, command, description, etcConfig, undefined, undefined, group, autoJoinGroup, restart, restartSec, autoEnable, autoStart);
194
+ break;
195
+ }
196
+ case ESimplifiedPlatform.WIN32:
197
+ throw new Error('Systemd not supported under win32');
198
+ }
199
+ }
200
+ uninstallSystemd(group, systemdServiceName) {
201
+ switch (simplifiedPlatform()) {
202
+ case ESimplifiedPlatform.POSIX:
203
+ commonsSystemdUninstall(systemdServiceName === undefined ? this.name : systemdServiceName, group);
204
+ break;
205
+ case ESimplifiedPlatform.WIN32:
206
+ throw new Error('Systemd not supported under win32');
207
+ }
208
+ }
209
+ autoSystemd(command, description, group, autoJoinGroup = false, restart = 'always', restartSec = 5, autoEnable = true, autoStart = false, systemdServiceName) {
210
+ const direction = this.getArgs().getFirstValueOrUndefined('systemd');
211
+ if (!direction)
212
+ return;
213
+ switch (direction) {
214
+ case 'install':
215
+ commonsOutputDoing('Installing systemd service');
216
+ try {
217
+ this.installSystemd(command, description, group, autoJoinGroup, restart, restartSec, autoEnable, autoStart, systemdServiceName);
218
+ commonsOutputSuccess();
219
+ }
220
+ catch (e) {
221
+ commonsOutputFail(e.message);
222
+ commonsOutputError(e.message);
223
+ }
224
+ break;
225
+ case 'uninstall':
226
+ commonsOutputDoing('Uninstalling systemd service');
227
+ try {
228
+ this.uninstallSystemd();
229
+ commonsOutputSuccess();
230
+ }
231
+ catch (e) {
232
+ commonsOutputFail(e.message);
233
+ commonsOutputError(e.message);
234
+ }
235
+ break;
236
+ default:
237
+ commonsOutputError('Unknown command for --systemd. Use either install or uninstall');
238
+ process.exit(1);
239
+ }
240
+ process.exit(0);
241
+ }
242
+ }
243
+ //# sourceMappingURL=commons.app.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commons.app.mjs","sourceRoot":"","sources":["../../src/apps/commons.app.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,QAAQ,MAAM,MAAM,CAAC;AAEjC,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,mBAAmB,EAAmC,MAAM,oBAAoB,CAAC;AAC1I,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAEL,8BAA8B,EAC9B,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,oCAAoC,EACpC,sBAAsB,EACtB,iBAAiB,EACjB,u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1B,YAAqB,KAAK,EAC1B,kBAA2B;QAE5B,MAAM,SAAS,GAAqB,IAAI,CAAC,OAAO,EAAE,CAAC,wBAAwB,CAAC,SAAS,CAAC,CAAC;QACvF,IAAI,CAAC,SAAS;YAAE,OAAO;QAEvB,QAAQ,SAAS,EAAE,CAAC;YACnB,KAAK,SAAS;gBACb,kBAAkB,CAAC,4BAA4B,CAAC,CAAC;gBAEjD,IAAI,CAAC;oBACJ,IAAI,CAAC,cAAc,CACjB,OAAO,EACP,WAAW,EACX,KAAK,EACL,aAAa,EACb,OAAO,EACP,UAAU,EACV,UAAU,EACV,SAAS,EACT,kBAAkB,CACnB,CAAC;oBACF,oBAAoB,EAAE,CAAC;gBACxB,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACZ,iBAAiB,CAAE,CAAW,CAAC,OAAO,CAAC,CAAC;oBACxC,kBAAkB,CAAE,CAAW,CAAC,OAAO,CAAC,CAAC;gBAC1C,CAAC;gBACD,MAAM;YACP,KAAK,WAAW;gBACf,kBAAkB,CAAC,8BAA8B,CAAC,CAAC;gBAEnD,IAAI,CAAC;oBACJ,IAAI,CAAC,gBAAgB,EAAE,CAAC;oBACxB,oBAAoB,EAAE,CAAC;gBACxB,CAAC;gBAAC,OAAO,CAAC,EAAE,CAAC;oBACZ,iBAAiB,CAAE,CAAW,CAAC,OAAO,CAAC,CAAC;oBACxC,kBAAkB,CAAE,CAAW,CAAC,OAAO,CAAC,CAAC;gBAC1C,CAAC;gBACD,MAAM;YACP;gBACC,kBAAkB,CAAC,gEAAgE,CAAC,CAAC;gBACrF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC;CACD"}
@@ -0,0 +1,4 @@
1
+ import { assertSet, CommonsBareApp } from './apps/commons-bare.app.mjs';
2
+ import { CommonsApp } from './apps/commons.app.mjs';
3
+ import { TCommonsDependencies, isTCommonsDependencies, ICommonsPackageJson, isICommonsPackageJson } from './interfaces/icommons-package-json.mjs';
4
+ export { assertSet, CommonsBareApp, CommonsApp, TCommonsDependencies, isTCommonsDependencies, ICommonsPackageJson, isICommonsPackageJson };
package/dist/index.mjs ADDED
@@ -0,0 +1,5 @@
1
+ import { assertSet, CommonsBareApp } from './apps/commons-bare.app.mjs';
2
+ import { CommonsApp } from './apps/commons.app.mjs';
3
+ import { isTCommonsDependencies, isICommonsPackageJson } from './interfaces/icommons-package-json.mjs';
4
+ export { assertSet, CommonsBareApp, CommonsApp, isTCommonsDependencies, isICommonsPackageJson };
5
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAEL,sBAAsB,EAEtB,qBAAqB,EACtB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EACN,SAAS,EACT,cAAc,EACd,UAAU,EAEV,sBAAsB,EAEtB,qBAAqB,EACrB,CAAC"}
@@ -0,0 +1,12 @@
1
+ export type TCommonsDependencies = {
2
+ [name: string]: string;
3
+ };
4
+ export declare function isTCommonsDependencies(test: any): test is TCommonsDependencies;
5
+ export interface ICommonsPackageJson {
6
+ name: string;
7
+ version: string;
8
+ description?: string;
9
+ dependencies?: TCommonsDependencies;
10
+ devDependencies?: TCommonsDependencies;
11
+ }
12
+ export declare function isICommonsPackageJson(test: any): test is ICommonsPackageJson;
@@ -0,0 +1,18 @@
1
+ import { commonsTypeHasPropertyString, commonsTypeHasPropertyStringOrUndefined, commonsTypeHasPropertyTOrUndefined, commonsTypeIsStringPropertyObjectT } from 'tscommons-esm-core';
2
+ export function isTCommonsDependencies(test) {
3
+ return commonsTypeIsStringPropertyObjectT(test);
4
+ }
5
+ export function isICommonsPackageJson(test) {
6
+ if (!commonsTypeHasPropertyString(test, 'name'))
7
+ return false;
8
+ if (!commonsTypeHasPropertyString(test, 'version'))
9
+ return false;
10
+ if (!commonsTypeHasPropertyStringOrUndefined(test, 'description'))
11
+ return false;
12
+ if (!commonsTypeHasPropertyTOrUndefined(test, 'dependencies', isTCommonsDependencies))
13
+ return false;
14
+ if (!commonsTypeHasPropertyTOrUndefined(test, 'devDependencies', isTCommonsDependencies))
15
+ return false;
16
+ return true;
17
+ }
18
+ //# sourceMappingURL=icommons-package-json.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icommons-package-json.mjs","sourceRoot":"","sources":["../../src/interfaces/icommons-package-json.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,uCAAuC,EACvC,kCAAkC,EAClC,kCAAkC,EACnC,MAAM,oBAAoB,CAAC;AAM5B,MAAM,UAAU,sBAAsB,CAAC,IAAS;IAC/C,OAAO,kCAAkC,CAAC,IAAI,CAAC,CAAC;AACjD,CAAC;AAUD,MAAM,UAAU,qBAAqB,CAAC,IAAS;IAC9C,IAAI,CAAC,4BAA4B,CAAC,IAAI,EAAE,MAAM,CAAC;QAAE,OAAO,KAAK,CAAC;IAC9D,IAAI,CAAC,4BAA4B,CAAC,IAAI,EAAE,SAAS,CAAC;QAAE,OAAO,KAAK,CAAC;IACjE,IAAI,CAAC,uCAAuC,CAAC,IAAI,EAAE,aAAa,CAAC;QAAE,OAAO,KAAK,CAAC;IAChF,IAAI,CAAC,kCAAkC,CAAuB,IAAI,EAAE,cAAc,EAAE,sBAAsB,CAAC;QAAE,OAAO,KAAK,CAAC;IAC1H,IAAI,CAAC,kCAAkC,CAAuB,IAAI,EAAE,iBAAiB,EAAE,sBAAsB,CAAC;QAAE,OAAO,KAAK,CAAC;IAE7H,OAAO,IAAI,CAAC;AACb,CAAC"}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "nodecommons-esm-app",
3
+ "version": "0.0.2",
4
+ "description": "",
5
+ "scripts": {
6
+ "tsc": "./node_modules/typescript/bin/tsc",
7
+ "preprepare": "rm -rf ./dist; php ~/Dev/etim.php src/ && npm run tsc",
8
+ "publish-major": "rm -rf dist; npm run tsc && npx eslint . && npm run preprepare && npm version major && npm install && npm publish && git add . && git commit -m 'publish'",
9
+ "publish-minor": "rm -rf dist; npm run tsc && npx eslint . && npm run preprepare && npm version minor && npm install && npm publish && git add . && git commit -m 'publish'",
10
+ "publish-patch": "rm -rf dist; npm run tsc && npx eslint . && npm run preprepare && npm version patch && npm install && npm publish && git add . && git commit -m 'publish'"
11
+ },
12
+ "main": "dist/index.mjs",
13
+ "types": "dist/index.d.mjs",
14
+ "type": "module",
15
+ "author": "Pete Morris",
16
+ "license": "ISC",
17
+ "devDependencies": {
18
+ "@stylistic/eslint-plugin-ts": "^2.10.1",
19
+ "@types/node": "^22.9.0",
20
+ "eslint-plugin-import": "^2.31.0",
21
+ "eslint-plugin-prefer-arrow-functions": "^3.4.1",
22
+ "typescript": "^5.6.3",
23
+ "typescript-eslint": "^8.14.0"
24
+ },
25
+ "files": [
26
+ "dist/**/*"
27
+ ],
28
+ "dependencies": {
29
+ "nodecommons-esm-cli": "^0.0.2",
30
+ "nodecommons-esm-config": "^0.0.2",
31
+ "nodecommons-esm-file": "^0.0.2",
32
+ "nodecommons-esm-process": "^0.0.2",
33
+ "tscommons-esm-async": "^0.0.2",
34
+ "tscommons-esm-config": "^0.0.2",
35
+ "tscommons-esm-core": "^0.0.2"
36
+ }
37
+ }