@@ -41,111 +41,77 @@ yarn add @flex-development/pkg-types
4141
4242## Use
4343
44- ``` typescript
45- import type { PackageJson } from ' @flex-development/pkg-types'
46- import fs from ' node:fs'
47- import path from ' node:path'
48-
49- /**
50- * Enables or disables [`type`][1] in `package.json`.
51- *
52- * [1]: https://nodejs.org/api/packages.html#type
53- *
54- * @example
55- * toggle()
56- * @example
57- * toggle('off')
58- * @example
59- * toggle('on')
60- *
61- * @param {'off' | 'on'} [command] - Toggle command
62- * @return {void} Nothing when complete
63- */
64- function toggle(command ? : ' off' | ' on' ): void {
65- // see: https://yarnpkg.com/advanced/lifecycle-scripts#environment-variables
66- const { npm_package_json = ' package.json' } = process .env
67-
68- /**
69- * Absolute path to `package.json`.
70- *
71- * @const {string} pkgfile
72- */
73- const pkgfile: string = path .resolve (npm_package_json )
74-
75- /**
76- * `package.json` data.
77- *
78- * @var {PackageJson} pkg
79- */
80- let pkg: PackageJson = JSON .parse (fs .readFileSync (pkgfile , ' utf8' ))
81-
82- // toggle package type
83- pkg = Object .keys (pkg ).reduce <PackageJson >((acc , key ) => {
84- const [, type, prefix = ' ' ] = / ^ ((#? )type)$ / .exec (key ) ?? []
85-
86- if (type ) {
87- key = command
88- ? ` ${command === ' off' ? ' #' : ' ' }type `
89- : prefix
90- ? type .replace (new RegExp (' ^' + prefix ), ' ' )
91- : ' #' + type
92-
93- acc [key ] = pkg [type ]!
94- } else {
95- acc [key ] = pkg [key ]!
96- }
97-
98- return acc
99- }, {})
100-
101- // rewrite package.json
102- return void fs .writeFileSync (pkgfile , JSON .stringify (pkg , null , 2 ) + ' \n ' )
103- }
104-
105- export default toggle
44+ ``` ts
45+ import type {
46+ Condition ,
47+ ConditionMap ,
48+ ExportConditions ,
49+ Exports ,
50+ ExportsKey ,
51+ ExportsList ,
52+ ExportsObject ,
53+ ImportConditions ,
54+ Imports ,
55+ ImportsKey ,
56+ PackageJson ,
57+ PackageType ,
58+ SubpathExports
59+ } from ' @flex-development/pkg-types'
10660```
10761
108- Need this functionality? See [ ` toggle-pkg-type ` ] [ toggle-pkg-type ] \: blush:
109-
11062## API
11163
112- ### Interfaces
113-
114- - [ ` DependencyMap ` ] ( src/interfaces/dependency-map.ts )
115- - [ ` Directories ` ] ( src/interfaces/directories.ts )
116- - [ ` PackageJson ` ] ( src/interfaces/package-json.ts )
117- - [ ` PublishConfig ` ] ( src/interfaces/publish-config.ts )
118- - [ ` Scripts ` ] ( src/interfaces/scripts.ts )
119-
120- ### Types
121-
122- - [ ` Access ` ] ( src/types/access.ts )
123- - [ ` Bin ` ] ( src/types/bin.ts )
124- - [ ` Browser ` ] ( src/types/browser.ts )
125- - [ ` Bugs ` ] ( src/types/bugs.ts )
126- - [ ` CPU ` ] ( src/types/cpu.ts )
127- - [ ` DependencyMeta ` ] ( src/types/dependency-meta.ts )
128- - [ ` Engine ` ] ( src/types/engine.ts )
129- - [ ` Engines ` ] ( src/types/engines.ts )
130- - [ ` ExportCondition ` ] ( src/types/export-condition.ts )
131- - [ ` ExportConditions ` ] ( src/types/export-conditions.ts )
132- - [ ` Exports ` ] ( src/types/exports.ts )
133- - [ ` FundingInfo ` ] ( src/types/funding-info.ts )
134- - [ ` FundingType ` ] ( src/types/funding-type.ts )
135- - [ ` HoistingLimits ` ] ( src/types/hoisiting-limits.ts )
136- - [ ` ImportsKey ` ] ( src/types/imports-key.ts )
137- - [ ` Imports ` ] ( src/types/imports.ts )
138- - [ ` InstallConfig ` ] ( src/types/install-config.ts )
139- - [ ` LicenseObject ` ] ( src/types/license-object.ts )
140- - [ ` OS ` ] ( src/types/os.ts )
141- - [ ` PeerDependencyMeta ` ] ( src/types/peer-dependency-meta.ts )
142- - [ ` Person ` ] ( src/types/person.ts )
143- - [ ` Registry ` ] ( src/types/registry.ts )
144- - [ ` Repository ` ] ( src/types/repository.ts )
145- - [ ` SemanticVersion ` ] ( src/types/semantic-version.ts )
146- - [ ` Type ` ] ( src/types/type.ts )
147- - [ ` TypesVersions ` ] ( src/types/types-versions.ts )
148- - [ ` WorkspacesConfig ` ] ( src/types/workspaces-config.ts )
64+ - [ ` Access ` ] ( ./src/access.ts )
65+ - [ ` Bin ` ] ( ./src/bin.ts )
66+ - [ ` BinObject ` ] ( ./src/bin-object.ts )
67+ - [ ` Browser ` ] ( ./src/browser.ts )
68+ - [ ` BrowserObject ` ] ( ./src/browser-object.ts )
69+ - [ ` Bugs ` ] ( ./src/bugs.ts )
70+ - [ ` Condition ` ] ( ./src/condition.ts )
71+ - [ ` ConditionMap ` ] ( ./src/condition-map.ts )
72+ - [ ` Config ` ] ( ./src/config.ts )
73+ - [ ` CPU ` ] ( ./src/cpu.ts )
74+ - [ ` CPUMap ` ] ( ./src/cpu-map.ts )
75+ - [ ` Dependencies ` ] ( ./src/dependencies.ts )
76+ - [ ` DevDependencies ` ] ( ./src/dev-dependencies.ts )
77+ - [ ` Directories ` ] ( ./src/directories.ts )
78+ - [ ` Engine ` ] ( ./src/engine.ts )
79+ - [ ` EngineMap ` ] ( ./src/engine-map.ts )
80+ - [ ` Engines ` ] ( ./src/engines.ts )
81+ - [ ` ExportConditions ` ] ( ./src/export-conditions.ts )
82+ - [ ` Exports ` ] ( ./src/exports.ts )
83+ - [ ` ExportsKey ` ] ( ./src/exports-key.ts )
84+ - [ ` ExportsList ` ] ( ./src/exports-list.ts )
85+ - [ ` ExportsObject ` ] ( ./src/exports-object.ts )
86+ - [ ` ImportConditions ` ] ( ./src/import-conditions.ts )
87+ - [ ` Imports ` ] ( ./src/imports.ts )
88+ - [ ` ImportsKey ` ] ( ./src/imports-key.ts )
89+ - [ ` JsonArray ` ] ( ./src/json-array.ts )
90+ - [ ` JsonObject ` ] ( ./src/json-object.ts )
91+ - [ ` JsonPrimitive ` ] ( ./src/json-primitive.ts )
92+ - [ ` JsonValue ` ] ( ./src/json-value.ts )
93+ - [ ` LicenseInfo ` ] ( ./src/license-info.ts )
94+ - [ ` OptionalDependencies ` ] ( ./src/optional-dependencies.ts )
95+ - [ ` OS ` ] ( ./src/os.ts )
96+ - [ ` OSMap ` ] ( ./src/os-map.ts )
97+ - [ ` PackageJson ` ] ( ./src/package-json.ts )
98+ - [ ` PackageManager ` ] ( ./src/package-manager.ts )
99+ - [ ` PackageManagerMap ` ] ( ./src/package-manager-map.ts )
100+ - [ ` PackageType ` ] ( ./src/package-type.ts )
101+ - [ ` PeerDependencies ` ] ( ./src/peer-dependencies.ts )
102+ - [ ` PeerDependenciesMeta ` ] ( ./src/peer-dependencies-meta.ts )
103+ - [ ` PeerDependencyMetadata ` ] ( ./src/peer-dependency-metadata.ts )
104+ - [ ` People ` ] ( ./src/people.ts )
105+ - [ ` Person ` ] ( ./src/person.ts )
106+ - [ ` PublishConfig ` ] ( ./src/publish-config.ts )
107+ - [ ` RepositoryInfo ` ] ( ./src/repository-info.ts )
108+ - [ ` RepositoryType ` ] ( ./src/repository-type.ts )
109+ - [ ` RepositoryTypeMap ` ] ( ./src/repository-type-map.ts )
110+ - [ ` Scripts ` ] ( ./src/scripts.ts )
111+ - [ ` SemanticVersion ` ] ( ./src/semantic-version.ts )
112+ - [ ` SubpathExports ` ] ( ./src/subpath-exports.ts )
113+ - [ ` TypesVersions ` ] ( ./src/types-versions.ts )
114+ - [ ` WorkspacesConfig ` ] ( ./src/workspaces-config.ts )
149115
150116## Related
151117
@@ -155,7 +121,8 @@ Need this functionality? See [`toggle-pkg-type`][toggle-pkg-type] \:blush:
155121
156122See [ ` CONTRIBUTING.md ` ] ( CONTRIBUTING.md ) .
157123
158- [ toggle-pkg-type ] : https://github.com/flex-development/toggle-pkg-type
124+ This project has a [ code of conduct] ( ./CODE_OF_CONDUCT.md ) . By interacting with this repository, organization, or
125+ community you agree to abide by its terms.
159126
160127[ tsconfig-types ] : https://github.com/flex-development/tsconfig-types
161128
0 commit comments