@temir.ra/create-test115 0.0.15 → 0.0.16
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/package.json +1 -1
- package/dist/template/CHANGELOG.md +0 -5
- package/dist/template/README.md +0 -29
- package/dist/template/package.json +0 -32
- package/dist/template/scripts/build-cdn-map.json +0 -1
- package/dist/template/scripts/build-cdn.ts +0 -158
- package/dist/template/scripts/buildinfo.ts +0 -25
- package/dist/template/src/buildinfo.ts +0 -2
- package/dist/template/src/dev.ts +0 -5
- package/dist/template/src/index.ts +0 -0
- package/dist/template/tests/buildinfo.test.ts +0 -20
- package/dist/template/tsconfig.build.json +0 -18
- package/dist/template/tsconfig.json +0 -35
package/package.json
CHANGED
package/dist/template/README.md
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# Introduction
|
|
2
|
-
|
|
3
|
-
*<INTRO TEXT>*
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
1. [Quick Start](#quick-start)
|
|
8
|
-
2. [Documentation](#documentation)
|
|
9
|
-
3. [DevOps](#devops)
|
|
10
|
-
1. [Change Management](#change-management)
|
|
11
|
-
2. [Publish](#publish)
|
|
12
|
-
|
|
13
|
-
# Quick Start
|
|
14
|
-
|
|
15
|
-
*<QUICK START INSTRUCTIONS>*
|
|
16
|
-
|
|
17
|
-
# Documentation
|
|
18
|
-
|
|
19
|
-
*<DOCUMENTATION>*
|
|
20
|
-
|
|
21
|
-
# DevOps
|
|
22
|
-
|
|
23
|
-
## Change Management
|
|
24
|
-
|
|
25
|
-
1. Create a new branch for the change.
|
|
26
|
-
2. Make the changes and commit them to the branch.
|
|
27
|
-
3. Bump the version in [`package.json`](package.json).
|
|
28
|
-
4. Add an entry for the new version in [`CHANGELOG.md`](CHANGELOG.md).
|
|
29
|
-
5. Pull request the branch.
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "",
|
|
3
|
-
"version": "",
|
|
4
|
-
"description": "",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"exports": {
|
|
7
|
-
".": {
|
|
8
|
-
"entrypoint": "./src/index.ts",
|
|
9
|
-
"browser": "./dist/index.bundle.js",
|
|
10
|
-
"import": "./dist/index.js",
|
|
11
|
-
"types": "./dist/index.d.ts"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"files": [
|
|
15
|
-
"dist"
|
|
16
|
-
],
|
|
17
|
-
"scripts": {
|
|
18
|
-
"clean": "rm -rf dist/",
|
|
19
|
-
"prebuild": "bun run scripts/buildinfo.ts",
|
|
20
|
-
"test": "bun test",
|
|
21
|
-
"build": "bun run build:lib && bun run build:cdn && bun run build:assets",
|
|
22
|
-
"build:lib": "tsc --project tsconfig.build.json",
|
|
23
|
-
"build:cdn": "bun run scripts/build-cdn.ts",
|
|
24
|
-
"build:assets": "cp src/assets/* dist/assets/",
|
|
25
|
-
"typecheck": "tsc --noEmit",
|
|
26
|
-
"dev": "bun run --watch src/dev.ts"
|
|
27
|
-
},
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"@types/bun": "latest",
|
|
30
|
-
"typescript": "^5.9.3"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'fs';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import CDN_MAP from 'scripts/build-cdn-map.json';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
interface ExportConditions {
|
|
7
|
-
|
|
8
|
-
[key: string]: string | undefined;
|
|
9
|
-
|
|
10
|
-
import?: string;
|
|
11
|
-
types?: string;
|
|
12
|
-
browser?: string;
|
|
13
|
-
entrypoint?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface DependencyMap {
|
|
17
|
-
[packageName: string]: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface PackageManifest {
|
|
21
|
-
version: string;
|
|
22
|
-
exports?: Record<string, ExportConditions>;
|
|
23
|
-
dependencies?: DependencyMap;
|
|
24
|
-
devDependencies?: DependencyMap;
|
|
25
|
-
peerDependencies?: DependencyMap;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function getManifest(packageIdentifier?: string): PackageManifest {
|
|
29
|
-
|
|
30
|
-
const manifestPath = packageIdentifier
|
|
31
|
-
? join('node_modules', packageIdentifier, 'package.json')
|
|
32
|
-
: 'package.json';
|
|
33
|
-
|
|
34
|
-
let manifest: PackageManifest;
|
|
35
|
-
try {
|
|
36
|
-
manifest = JSON.parse(readFileSync(manifestPath, 'utf-8'));
|
|
37
|
-
} catch {
|
|
38
|
-
if (packageIdentifier)
|
|
39
|
-
throw new Error("[build-cdn] Could not read manifest for '" + packageIdentifier + "' at '" + manifestPath + "'. Is it installed?");
|
|
40
|
-
else
|
|
41
|
-
throw new Error("[build-cdn] Could not read package manifest at '" + manifestPath + "'.");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return manifest;
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function getManifestEntrypoints(packageManifest: PackageManifest): string[] {
|
|
49
|
-
|
|
50
|
-
const exports = packageManifest.exports;
|
|
51
|
-
if (!exports) throw new Error('[build-cdn] No exports field found in package.json.');
|
|
52
|
-
|
|
53
|
-
const entrypoints = Object.entries(exports)
|
|
54
|
-
.map(([key, conditions]) => {
|
|
55
|
-
if (!conditions.entrypoint) throw new Error(`[build-cdn] Export '${key}' does not have an 'entrypoint' condition.`);
|
|
56
|
-
return conditions.entrypoint;
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
return entrypoints;
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function getPackageVersion(manifest: PackageManifest, packageIdentifier?: string): string {
|
|
64
|
-
|
|
65
|
-
let version: string | undefined;
|
|
66
|
-
if (packageIdentifier) {
|
|
67
|
-
|
|
68
|
-
const dependencies = {
|
|
69
|
-
...manifest.dependencies,
|
|
70
|
-
...manifest.devDependencies,
|
|
71
|
-
...manifest.peerDependencies,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
version = dependencies[packageIdentifier];
|
|
75
|
-
if (!version) throw new Error(`[build-cdn] Package '${packageIdentifier}' is not listed in dependencies.`);
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
if (!manifest.version) throw new Error('[build-cdn] Package manifest does not contain a version field.');
|
|
80
|
-
version = manifest.version;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return version;
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function resolveCdnUrl(importSpecifier: string, urlTemplate: string): string {
|
|
88
|
-
const manifest = getManifest();
|
|
89
|
-
const version = getPackageVersion(manifest, importSpecifier);
|
|
90
|
-
return urlTemplate.replace('<VERSION>', version);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const cdnRewritePlugin = {
|
|
94
|
-
name: 'cdn-rewrite',
|
|
95
|
-
setup(build: any) {
|
|
96
|
-
|
|
97
|
-
const resolved = new Map<string, string>();
|
|
98
|
-
for (const [importSpecifier, urlTemplate] of Object.entries(CDN_MAP) as [string, string][]) {
|
|
99
|
-
const url = resolveCdnUrl(importSpecifier, urlTemplate);
|
|
100
|
-
resolved.set(importSpecifier, url);
|
|
101
|
-
console.log(`[cdn-rewrite] '${importSpecifier}' → '${url}'`);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
build.onResolve({ filter: /.*/ }, (args: any) => {
|
|
105
|
-
const url = resolved.get(args.path);
|
|
106
|
-
if (url) return { path: url, external: true };
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const entrypoints = getManifestEntrypoints(getManifest());
|
|
114
|
-
console.log('[build-cdn] Entrypoints:', entrypoints);
|
|
115
|
-
|
|
116
|
-
let buildResult;
|
|
117
|
-
|
|
118
|
-
console.log('[build-cdn] Starting ESM CDN bundle build...');
|
|
119
|
-
buildResult = await Bun.build({
|
|
120
|
-
entrypoints,
|
|
121
|
-
outdir: 'dist',
|
|
122
|
-
naming: '[dir]/[name].bundle.[ext]',
|
|
123
|
-
target: 'browser',
|
|
124
|
-
format: 'esm',
|
|
125
|
-
minify: true,
|
|
126
|
-
sourcemap: 'external',
|
|
127
|
-
plugins: [cdnRewritePlugin],
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
if (!buildResult.success) {
|
|
131
|
-
console.error('[build-cdn] Build failed:');
|
|
132
|
-
for (const message of buildResult.logs) {
|
|
133
|
-
console.error(message);
|
|
134
|
-
}
|
|
135
|
-
process.exit(1);
|
|
136
|
-
}
|
|
137
|
-
console.log('[build-cdn] ESM CDN bundle build completed successfully.');
|
|
138
|
-
|
|
139
|
-
console.log('[build-cdn] Starting IIFE CDN bundle build...');
|
|
140
|
-
buildResult = await Bun.build({
|
|
141
|
-
entrypoints,
|
|
142
|
-
outdir: 'dist',
|
|
143
|
-
naming: '[dir]/[name].iife.[ext]',
|
|
144
|
-
target: 'browser',
|
|
145
|
-
format: 'iife',
|
|
146
|
-
minify: true,
|
|
147
|
-
sourcemap: 'external',
|
|
148
|
-
plugins: [cdnRewritePlugin],
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
if (!buildResult.success) {
|
|
152
|
-
console.error('[build-cdn] Build failed:');
|
|
153
|
-
for (const message of buildResult.logs) {
|
|
154
|
-
console.error(message);
|
|
155
|
-
}
|
|
156
|
-
process.exit(1);
|
|
157
|
-
}
|
|
158
|
-
console.log('[build-cdn] IIFE CDN bundle build completed successfully.');
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { execSync } from 'child_process';
|
|
2
|
-
import { writeFileSync } from 'fs';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const BUILD_INFO_FILE = join('src', 'buildinfo.ts');
|
|
7
|
-
const GIT_COMMAND = 'git rev-parse --short HEAD';
|
|
8
|
-
|
|
9
|
-
const version = process.env.npm_package_version ?? '0.0.0';
|
|
10
|
-
|
|
11
|
-
let gitHash = '';
|
|
12
|
-
try {
|
|
13
|
-
gitHash = execSync(GIT_COMMAND, { stdio: ['ignore', 'pipe', 'ignore'] })
|
|
14
|
-
.toString()
|
|
15
|
-
.trim();
|
|
16
|
-
} catch { }
|
|
17
|
-
|
|
18
|
-
const buildInfo = gitHash ? `${version}+${gitHash}` : version;
|
|
19
|
-
|
|
20
|
-
writeFileSync(
|
|
21
|
-
BUILD_INFO_FILE,
|
|
22
|
-
`// auto-generated by scripts/buildinfo.ts\nexport const buildInfo = '${buildInfo}';\n`
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
console.log(`'${BUILD_INFO_FILE}' has been updated with build info: ${buildInfo}`);
|
package/dist/template/src/dev.ts
DELETED
|
File without changes
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'bun:test';
|
|
2
|
-
import { buildInfo } from '@/buildinfo';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
describe('buildInfo', () => {
|
|
6
|
-
|
|
7
|
-
it('should follow semantic versioning format with optional commit hash', () => {
|
|
8
|
-
expect(buildInfo).toMatch(/^\d+\.\d+\.\d+(\+[0-9a-f]+)?$/);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('should not contain whitespace', () => {
|
|
12
|
-
expect(buildInfo).not.toMatch(/\s/);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('should not be empty or dash', () => {
|
|
16
|
-
expect(buildInfo.length).toBeGreaterThan(0);
|
|
17
|
-
expect(buildInfo).not.toBe('-');
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"module": "nodenext",
|
|
5
|
-
"moduleResolution": "nodenext",
|
|
6
|
-
"emitDeclarationOnly": false,
|
|
7
|
-
},
|
|
8
|
-
"include": [
|
|
9
|
-
"src/**/*.ts"
|
|
10
|
-
],
|
|
11
|
-
"exclude": [
|
|
12
|
-
"src/dev.ts",
|
|
13
|
-
"node_modules",
|
|
14
|
-
"dist",
|
|
15
|
-
"tests",
|
|
16
|
-
"scripts"
|
|
17
|
-
]
|
|
18
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2022",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"lib": [
|
|
6
|
-
"ES2022",
|
|
7
|
-
"DOM"
|
|
8
|
-
],
|
|
9
|
-
"moduleResolution": "bundler",
|
|
10
|
-
"strict": true,
|
|
11
|
-
"esModuleInterop": true,
|
|
12
|
-
"skipLibCheck": true,
|
|
13
|
-
"forceConsistentCasingInFileNames": true,
|
|
14
|
-
"resolveJsonModule": true,
|
|
15
|
-
"declaration": true,
|
|
16
|
-
"declarationMap": true,
|
|
17
|
-
"emitDeclarationOnly": true,
|
|
18
|
-
"outDir": "./dist",
|
|
19
|
-
"baseUrl": ".",
|
|
20
|
-
"paths": {
|
|
21
|
-
"@/*": [
|
|
22
|
-
"src/*"
|
|
23
|
-
]
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"include": [
|
|
27
|
-
"src/**/*.ts",
|
|
28
|
-
"tests/**/*.ts",
|
|
29
|
-
"scripts/**/*.ts"
|
|
30
|
-
],
|
|
31
|
-
"exclude": [
|
|
32
|
-
"node_modules",
|
|
33
|
-
"dist"
|
|
34
|
-
]
|
|
35
|
-
}
|