@monoweave/types 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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ # Changelog
2
+
3
+ <!-- MONOWEAVE:BELOW -->
4
+
5
+ ## [0.0.2](https://github.com/monoweave/monoweave/compare/@monoweave/types@0.0.1...@monoweave/types@0.0.2) "@monoweave/types" (2024-02-29)<a name="0.0.2"></a>
6
+
7
+ ### Bug Fixes
8
+
9
+ * initial commit, forked from tophat/monodeploy under Apache 2.0 license (#1) ([2410d1c](https://github.com/monoweave/monoweave/commits/2410d1c))
10
+
11
+
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # Monoweave Types
2
+
3
+ This package contains common types used across monoweave packages.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ yarn add @monoweave/types
9
+ ```
package/lib/types.d.ts ADDED
@@ -0,0 +1,337 @@
1
+ /// <reference types="node" />
2
+ import type { Configuration, Project, Report, Workspace } from '@yarnpkg/core';
3
+ import type { AsyncSeriesHook } from 'tapable';
4
+ export type RecursivePartial<T> = {
5
+ [P in keyof T]?: T[P] extends Record<string, unknown> ? RecursivePartial<T[P]> : T[P];
6
+ };
7
+ export declare enum RegistryMode {
8
+ NPM = "npm",
9
+ Manifest = "manifest"
10
+ }
11
+ export interface MonoweaveConfiguration {
12
+ /**
13
+ * The working directory to run all operations from. Defaults to the
14
+ * current working directory.
15
+ *
16
+ * @default cwd
17
+ */
18
+ cwd: string;
19
+ /**
20
+ * Log levels. Control verbosity of output.
21
+ *
22
+ * DEBUG: 0
23
+ * INFO: 1
24
+ * WARNING: 2
25
+ * ERROR: 3
26
+ *
27
+ * @default 1
28
+ */
29
+ logLevel?: '0' | '1' | '2' | '3' | null;
30
+ /**
31
+ * The NPM registry URL for fetching package information, and publishing
32
+ * packages. Note that this overrides any publishConfig.registryUrl or
33
+ * Yarn RC configuration.
34
+ *
35
+ * @default [Yarn Configuration](https://yarnpkg.com/configuration/yarnrc)
36
+ */
37
+ registryUrl?: string;
38
+ /**
39
+ * By default the latest package versions upon which the version strategy
40
+ * is applied is taken from the NPM registry (npm mode). If registryMode is set to 'manifest'
41
+ * the latest version is instead taken from the package.json files. Note that
42
+ * 'manifest' mode is incompatible with prerelease mode.
43
+ *
44
+ * Can be either 'npm' or 'manifest'.
45
+ *
46
+ * @default "npm"
47
+ */
48
+ registryMode: RegistryMode;
49
+ /**
50
+ * If enabled, any operation performing a destructive action on an external
51
+ * system is skipped over. This includes publishing to NPM, committing to git,
52
+ * and execution of lifecycle scripts. Use dry run to preview publish changes,
53
+ * and to validate your configuration.
54
+ *
55
+ * @default false
56
+ */
57
+ dryRun: boolean;
58
+ git: {
59
+ /**
60
+ * The base git ref to using as the starting point of package change
61
+ * discovery. If not set, this will default to the last tagged commit.
62
+ * You usually do not want to set this.
63
+ *
64
+ * @default _last tagged commit_
65
+ */
66
+ baseBranch?: string;
67
+ /**
68
+ * The git ref which marks the "end point" of package change discovery.
69
+ * This defaults to HEAD. You usually do not want to set this.
70
+ *
71
+ * @default HEAD
72
+ */
73
+ commitSha: string;
74
+ /**
75
+ * The git remote name to push tags and the release commit to. Defaults
76
+ * to origin.
77
+ *
78
+ * @default origin
79
+ */
80
+ remote: string;
81
+ /**
82
+ * Whether to push to the git remote. This works in conjunction with the
83
+ * git.tag and autoCommit options, thus allowing you to create the tags
84
+ * and release commit automatically while deferring the actual push.
85
+ *
86
+ * @default false
87
+ */
88
+ push: boolean;
89
+ /**
90
+ * Whether to create git tags to track the releases. It is useful to disable this
91
+ * when publishing to a test registry, where you do not want to modify the main git branch.
92
+ *
93
+ * @default true
94
+ */
95
+ tag: boolean;
96
+ };
97
+ /**
98
+ * A conventional changelog config package name. This is required for changelog generation.
99
+ * This config determines the changelog format, as well as the version strategy determiner.
100
+ *
101
+ * @default _Partial internal implementation (not recommended)_
102
+ */
103
+ conventionalChangelogConfig?: string | {
104
+ name: string;
105
+ [key: string]: unknown;
106
+ };
107
+ /**
108
+ * The filename to write the changeset to. This is a metadata file which after a monoweave
109
+ * run, will contain change history useful for external scripts. Set to '-' to write to stdout.
110
+ */
111
+ changesetFilename?: string;
112
+ /**
113
+ * Whether to resume publishing from a changeset. This option can only be set from the command line,
114
+ * and cannot be provided via a monoweave.config.js file. This feature is _not_ available yet. If
115
+ * you're interested in this feature, please leave comments on the [GitHub Issue](https://github.com/monoweave/monoweave/issues/323).
116
+ */
117
+ applyChangeset?: boolean;
118
+ /**
119
+ * The filename to write changelogs to, assuming a conventional changelog config has been set.
120
+ * Use '<packageDir>' to reference the cwd of an individual workspace. You should also enable
121
+ * 'autoCommit' when this is set so that the changelogs are committed to your repo.
122
+ */
123
+ changelogFilename?: string;
124
+ /**
125
+ * An array of micromatch globs which will be used to filter out modified files. You can
126
+ * use this to skip modifications to 'test files' as part of the 'how this package changed'
127
+ * determination.
128
+ *
129
+ * @default []
130
+ */
131
+ changesetIgnorePatterns?: string[];
132
+ /**
133
+ * By default, the changeset and changelog files are not written in dry run mode, as
134
+ * they constitute a change to an external system. Enable force write to write these
135
+ * change files, which can be useful for generating publish previews.
136
+ *
137
+ * @default false
138
+ */
139
+ forceWriteChangeFiles: boolean;
140
+ /**
141
+ * This overrides the access defined in the publishConfig of individual
142
+ * workspaces. Set this to 'infer' to respect individual workspace configurations.
143
+ *
144
+ * @default infer
145
+ */
146
+ access?: 'infer' | 'public' | 'restricted';
147
+ /**
148
+ * Whether to persist package.json modifications, i.e. updating the dependency versions
149
+ * and the version field of each published workspace. Most publishing tools act as if this
150
+ * is enabled. It can be useful to disable version persistence if you do not want your CI
151
+ * environment to write back to your Git repository. Useful for runners like Jenkins. You
152
+ * should also enable 'autoCommit' when this is set so that the changelogs are committed
153
+ * to your repo.
154
+ *
155
+ * @default false
156
+ */
157
+ persistVersions: boolean;
158
+ /**
159
+ * Customizations to the version strategy logic.
160
+ *
161
+ * @default undefined
162
+ */
163
+ versionStrategy?: VersionStrategyConfiguration;
164
+ /**
165
+ * Whether to automatically create a release commit after a publish. If using autoCommit,
166
+ * you must also have one of 'persistVersions' or 'changelogFilename' set.
167
+ *
168
+ * @default false
169
+ */
170
+ autoCommit: boolean;
171
+ /**
172
+ * The commit message to use when autoCommit is enabled.
173
+ *
174
+ * @default "chore: release [skip ci]"
175
+ */
176
+ autoCommitMessage: string;
177
+ /**
178
+ * An array of regular expressions which will be used to filter out commits from the
179
+ * explicit package bump detection. The patterns are matched against commits of the form:
180
+ * <sha> <newline> <body>
181
+ *
182
+ * @default []
183
+ */
184
+ commitIgnorePatterns?: (string | RegExp)[];
185
+ /**
186
+ * The manifest field name to use in workspace grouping. All packages
187
+ * within a group will always have the same version and git tag. If unset, all packages
188
+ * are versioned independently. Since the group is used for the git tag, it must not contain
189
+ * any characters not supported in a git tag.
190
+ *
191
+ * You can use a '.' to access nested properties in the manifest file. For example,
192
+ * you can use 'publishConfig.group' to access the group property in your publishConfig.
193
+ */
194
+ packageGroupManifestField?: string;
195
+ /**
196
+ * Package group specific settings. Note that if no packageGroupManifestField is set,
197
+ * each workspace is in its own group.
198
+ */
199
+ packageGroups?: Record<string, GroupConfiguration>;
200
+ /**
201
+ * Whether to run the lifecycle scripts of the packages to publish in topological order,
202
+ * based on dependencies and peerDependencies. This excludes devDependencies from the graph.
203
+ *
204
+ * @default false
205
+ */
206
+ topological: boolean;
207
+ /**
208
+ * Similar to topological, however also consider devDependencies.
209
+ *
210
+ * @default false
211
+ */
212
+ topologicalDev: boolean;
213
+ /**
214
+ * The maximum number of packages whose lifecycle scripts can be run in parallel. Similar to
215
+ * concurrency in Lerna.
216
+ *
217
+ * @default 0 _(No Limit)_
218
+ */
219
+ jobs: number;
220
+ /**
221
+ * The maximum number of package metadata to read from the NPM registry simultaneously.
222
+ * If no default is set, or set to 0, Monoweave will use its discretion.
223
+ *
224
+ * @default 0 _(Internal Implementation Detail)_
225
+ */
226
+ maxConcurrentReads: number;
227
+ /**
228
+ * The maximum number of packages to publish to the NPM registry simultaneously. We have seen
229
+ * issues in the past with too many concurrent writes for private registries.
230
+ * If no default is set, or set to 0, Monoweave will use its discretion.
231
+ *
232
+ * @default 0 _(Internal Implementation Detail)_
233
+ */
234
+ maxConcurrentWrites: number;
235
+ /**
236
+ * An array of Monoweave plugins. See the plugin section of the documentation for more
237
+ * information.
238
+ *
239
+ * @default []
240
+ */
241
+ plugins?: (string | [string, unknown])[];
242
+ /**
243
+ * Whether to run Monoweave in Prerelease mode. In prerelease mode, versions are not
244
+ * published to the latest npm dist tag. This is meant for release candidates, and beta
245
+ * versions. Version strategy behaviour is also impacted by this mode.
246
+ *
247
+ * @default false
248
+ */
249
+ prerelease: boolean;
250
+ /**
251
+ * The identifier to use in the prerelease tag. Defaults to 'rc' as in '1.0.0-rc.1'.
252
+ *
253
+ * @default "rc"
254
+ */
255
+ prereleaseId: string;
256
+ /**
257
+ * The npm dist-tag to publish to in prerelease mode. Defaults to 'next'.
258
+ *
259
+ * @default "next"
260
+ */
261
+ prereleaseNPMTag: string;
262
+ }
263
+ export interface VersionStrategyConfiguration {
264
+ /**
265
+ * When patching dependencies in package manifests, this setting controls
266
+ * how to set the version for peerDependencies. The default is "patch".
267
+ * If set to "minor", the peerDependency version is rounded down to the nearest
268
+ * "minor" version. If set to "major", the peerDependency version is rounded down
269
+ * to the nearest major.
270
+ *
271
+ * In a future version of Monoweave, the default will be changed to 'minor'.
272
+ *
273
+ * @default "patch"
274
+ */
275
+ coerceImplicitPeerDependency?: 'patch' | 'minor' | 'major';
276
+ /**
277
+ * If specified, when determining explicit version strategies, a '3' or null
278
+ * returned from the strategy determiner will be coerced to the minimum strategy.
279
+ * This can be used to override a third party conventional changelog config such that
280
+ * all package changes are treated as a 'patch' at a minimum. Without this override,
281
+ * a strategy determiner, depending on the configuration, may treat a certain commit
282
+ * as a "no-op".
283
+ *
284
+ * @default undefined
285
+ */
286
+ minimumStrategy?: 'patch' | 'minor' | 'major' | undefined;
287
+ }
288
+ export interface GroupConfiguration {
289
+ /**
290
+ * By default the latest package versions upon which the version strategy
291
+ * is applied is taken from the NPM registry (npm mode). If registryMode is set to 'manifest'
292
+ * the latest version is instead taken from the package.json files. Note that
293
+ * 'manifest' mode is incompatible with prerelease mode.
294
+ *
295
+ * @default "npm"
296
+ */
297
+ registryMode: RegistryMode;
298
+ }
299
+ export interface YarnContext {
300
+ configuration: Configuration;
301
+ project: Project;
302
+ workspace: Workspace;
303
+ report: Report;
304
+ hooks?: PluginHooks;
305
+ }
306
+ export interface PluginHooks {
307
+ onReleaseAvailable: AsyncSeriesHook<[
308
+ Readonly<YarnContext>,
309
+ Readonly<MonoweaveConfiguration>,
310
+ Readonly<ChangesetSchema>
311
+ ], void>;
312
+ }
313
+ export interface CommitMessage {
314
+ sha: string;
315
+ body: string;
316
+ }
317
+ export type PackageTagMap = Map<string, Record<string, string | undefined> & {
318
+ latest: string;
319
+ }>;
320
+ export type PackageVersionMap = Map<string, string>;
321
+ export type PackageStrategyType = 'major' | 'minor' | 'patch';
322
+ export type PackageStrategyMap = Map<string, {
323
+ type: PackageStrategyType;
324
+ commits: CommitMessage[];
325
+ }>;
326
+ export type StrategyDeterminer = (commits: string[]) => Promise<number>;
327
+ export interface ChangesetRecord {
328
+ version: string;
329
+ previousVersion?: string | null;
330
+ changelog: string | null;
331
+ tag: string | null;
332
+ strategy?: PackageStrategyType | null;
333
+ group: string;
334
+ }
335
+ export type ChangesetSchema = Record<string, ChangesetRecord>;
336
+ export declare function isNodeError<T = NodeJS.ErrnoException>(error: unknown): error is T;
337
+ export type MonoweaveConfigFile = RecursivePartial<Omit<MonoweaveConfiguration, 'cwd'>>;
package/lib/types.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isNodeError = exports.RegistryMode = void 0;
4
+ var RegistryMode;
5
+ (function (RegistryMode) {
6
+ RegistryMode["NPM"] = "npm";
7
+ RegistryMode["Manifest"] = "manifest";
8
+ })(RegistryMode || (exports.RegistryMode = RegistryMode = {}));
9
+ function isNodeError(error) {
10
+ return error instanceof Error || error?.code !== undefined;
11
+ }
12
+ exports.isNodeError = isNodeError;
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@monoweave/types",
3
+ "version": "0.0.2",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/monoweave/monoweave.git",
7
+ "directory": "packages/types"
8
+ },
9
+ "author": {
10
+ "name": "noahnu",
11
+ "url": "https://monoweave.github.io"
12
+ },
13
+ "license": "BSD-3",
14
+ "main": "./lib/types.js",
15
+ "publishConfig": {
16
+ "main": "./lib/types.js",
17
+ "types": "./lib/types.d.ts",
18
+ "registry": "https://registry.npmjs.org/",
19
+ "access": "public"
20
+ },
21
+ "group": "monoweave",
22
+ "files": [
23
+ "lib"
24
+ ],
25
+ "scripts": {
26
+ "clean": "run workspace:clean \"$(pwd)\"",
27
+ "types:watch": "run workspace:types:watch \"$(pwd)\"",
28
+ "test:watch": "run workspace:test:watch \"$(pwd)\"",
29
+ "build:watch": "run workspace:build:watch \"$(pwd)\"",
30
+ "prepack": "run workspace:build \"$(pwd)\"",
31
+ "docs": "ts-node --transpile-only ./generateDocs.ts"
32
+ },
33
+ "dependencies": {
34
+ "tapable": "^2.2.1"
35
+ },
36
+ "peerDependencies": {
37
+ "@yarnpkg/core": "^4.0.3"
38
+ },
39
+ "devDependencies": {
40
+ "@types/jest": "^29.5.6",
41
+ "@types/node": "^18.18.6",
42
+ "@yarnpkg/core": "^4.0.3",
43
+ "ts-node": "^10.9.1",
44
+ "typedoc": "^0.25.2",
45
+ "typescript": "5.2.2"
46
+ },
47
+ "types": "./lib/types.d.ts"
48
+ }