elrh-cosca 0.2.0 → 0.2.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/README.md +50 -10
- package/dist/elrh-cosca.mjs +847 -801
- package/dist/types/_private/fetch-file.d.ts +1 -0
- package/dist/types/functions/create-file-from-web-template.d.ts +1 -0
- package/dist/types/main.d.ts +9 -6
- package/dist/types/utils/parse-qualified-path.d.ts +8 -0
- package/dist/types/utils/resolve-package-path.d.ts +6 -0
- package/package.json +1 -3
- package/test/cosca-test.js +11 -12
- package/dist/types/utils/resolve-package.d.ts +0 -14
- package/dist/types/utils/resolve-path.d.ts +0 -12
- /package/dist/types/{utils/better-deep-merge.d.ts → _private/deep-merge-object.d.ts} +0 -0
- /package/dist/types/{lib → functions}/create-file-from-template.d.ts +0 -0
- /package/dist/types/{lib → functions}/update-config-file.d.ts +0 -0
- /package/dist/types/{lib → functions}/update-json-file.d.ts +0 -0
- /package/dist/types/{lib → functions}/update-text-file.d.ts +0 -0
- /package/dist/types/{lib → terminal}/prompt-user.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function fetchFile(url: string): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createFileFromWebTemplate(webSource: string, targetFile: string, force?: boolean): Promise<void>;
|
package/dist/types/main.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { createFileFromTemplate } from './
|
|
2
|
-
import {
|
|
3
|
-
import { updateConfigFile } from './
|
|
4
|
-
import { updateJsonFile } from './
|
|
5
|
-
import { updateTextFile } from './
|
|
6
|
-
|
|
1
|
+
import { createFileFromTemplate } from './functions/create-file-from-template';
|
|
2
|
+
import { createFileFromWebTemplate } from './functions/create-file-from-web-template';
|
|
3
|
+
import { updateConfigFile } from './functions/update-config-file';
|
|
4
|
+
import { updateJsonFile } from './functions/update-json-file';
|
|
5
|
+
import { updateTextFile } from './functions/update-text-file';
|
|
6
|
+
import { promptUser } from './terminal/prompt-user';
|
|
7
|
+
import { parseQualifiedPath } from './utils/parse-qualified-path';
|
|
8
|
+
import { resolvePackagePath } from './utils/resolve-package-path';
|
|
9
|
+
export { createFileFromTemplate, createFileFromWebTemplate, updateConfigFile, updateJsonFile, updateTextFile, promptUser, parseQualifiedPath, resolvePackagePath, };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expects path to file in `"package:relative/path/to/file"` format and splits it into `{ pkg, file }`.
|
|
3
|
+
* The package name can be scoped (e.g. `@scope/package`). Throws error on invalid input.
|
|
4
|
+
*/
|
|
5
|
+
export declare function parseQualifiedPath(path: string): {
|
|
6
|
+
pkg: string;
|
|
7
|
+
file: string;
|
|
8
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elrh-cosca",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -12,11 +12,9 @@
|
|
|
12
12
|
".": {
|
|
13
13
|
"types": "./dist/types/index.d.ts",
|
|
14
14
|
"import": "./dist/elrh-cosca.mjs",
|
|
15
|
-
"require": "./dist/elrh-cosca.cjs",
|
|
16
15
|
"default": "./dist/elrh-cosca.mjs"
|
|
17
16
|
}
|
|
18
17
|
},
|
|
19
|
-
"main": "./dist/elrh-cosca.cjs",
|
|
20
18
|
"module": "./dist/elrh-cosca.mjs",
|
|
21
19
|
"types": "./dist/types/index.d.ts",
|
|
22
20
|
"devDependencies": {
|
package/test/cosca-test.js
CHANGED
|
@@ -2,34 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
// manual test script for COSCA functions
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
createFileFromTemplate, promptUser, updateConfigFile, updateJsonFile, updateTextFile
|
|
5
|
+
import {
|
|
6
|
+
createFileFromTemplate, createFileFromWebTemplate, promptUser, updateConfigFile, updateJsonFile, updateTextFile
|
|
7
7
|
} from '../dist/elrh-cosca.mjs'
|
|
8
8
|
|
|
9
9
|
async function main() {
|
|
10
|
-
/*
|
|
11
10
|
console.log('Test promptUser')
|
|
12
11
|
const input = await promptUser('Is it today?')
|
|
13
12
|
console.log('User input:', input)
|
|
14
13
|
|
|
15
14
|
console.log('\nTest createFileFromTemplate')
|
|
16
|
-
await createFileFromTemplate('
|
|
17
|
-
await createFileFromTemplate('elrh-cosca:
|
|
18
|
-
|
|
15
|
+
await createFileFromTemplate('vitest:README.md', 'test/snapshots/test.file1')
|
|
16
|
+
await createFileFromTemplate('elrh-cosca:test/fixtures/text-file.txt', 'test/snapshots/test.file2')
|
|
17
|
+
|
|
18
|
+
console.log('\nTest createFileFromWebTemplate')
|
|
19
|
+
await createFileFromWebTemplate('https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/heads/main/config/vitest.config.ts.template', 'test/snapshots/test.file3')
|
|
19
20
|
|
|
20
21
|
console.log('\nTest updateConfigFile')
|
|
21
|
-
await updateConfigFile('test/
|
|
22
|
+
await updateConfigFile('test/fixtures/config-file-default.ts', { compatibilityDate: '2025-08-26', extends: ['nuxt-iignis'], cosca: { exists: true, data: ['some', 'other'], raw: 'war' } })
|
|
22
23
|
|
|
23
|
-
/*
|
|
24
24
|
console.log('\nTest updateJsonFile')
|
|
25
|
-
await updateJsonFile('
|
|
25
|
+
await updateJsonFile('test/fixtures/json-file.json', 'scripts', { 'cosca' : 'cosca' })
|
|
26
26
|
|
|
27
27
|
console.log('\nTest updateTextFile')
|
|
28
|
-
await updateTextFile('.
|
|
29
|
-
*/
|
|
28
|
+
await updateTextFile('test/fixtures/text-file.txt', ['# COSCA'])
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
main().catch((err) => {
|
|
33
|
-
console.error(
|
|
32
|
+
console.error(err)
|
|
34
33
|
process.exit(1)
|
|
35
34
|
})
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Expects path to file template in `"package:relative/path/to/file"` format and splits it into `{ pkg, file }`.
|
|
3
|
-
* Throws error on invalid input.
|
|
4
|
-
*/
|
|
5
|
-
export declare function parseTemplatePath(input: string): {
|
|
6
|
-
pkg: string;
|
|
7
|
-
file: string;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Resolve a package's installed root directory *from the target app*.
|
|
11
|
-
* Package name can be scoped.
|
|
12
|
-
* Works with npm/yarn/pnpm, hoisting or not.
|
|
13
|
-
*/
|
|
14
|
-
export declare function resolvePackagePath(packageName: string): string;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Normalized __filename that works in both ESM (.mjs) and CJS (.cjs).
|
|
3
|
-
* In CJS, __filename is available as a global variable.
|
|
4
|
-
* In MJS, import.meta.url is available instead.
|
|
5
|
-
*/
|
|
6
|
-
export declare const module_file: string;
|
|
7
|
-
/**
|
|
8
|
-
* Normalized __dirname that works in both ESM (.mjs) and CJS (.cjs).
|
|
9
|
-
* In CJS, __filename is available as a global variable.
|
|
10
|
-
* In MJS, import.meta.url is available instead.
|
|
11
|
-
*/
|
|
12
|
-
export declare const module_dir: string;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|