Skip to content

Commit 4997ab5

Browse files
committed
chore: first pass at generators
1 parent cfde157 commit 4997ab5

File tree

10 files changed

+278
-0
lines changed

10 files changed

+278
-0
lines changed

turbo/generators/config.ts

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import type { PlopTypes } from '@turbo/gen';
2+
3+
export default function generator(plop: PlopTypes.NodePlopAPI): void {
4+
// SDK/Utilities Package Generator
5+
plop.setGenerator('sdk', {
6+
description: 'Create a new SDK or utility package',
7+
prompts: [
8+
{
9+
type: 'input',
10+
name: 'name',
11+
message:
12+
"What is the name of the package? (e.g., 'sdk-trace-web', 'context-zone')",
13+
},
14+
{
15+
type: 'input',
16+
name: 'description',
17+
message: 'What is the package description?',
18+
},
19+
],
20+
actions: [
21+
{
22+
type: 'add',
23+
path: 'packages/{{kebabCase name}}/package.json',
24+
templateFile: 'templates/sdk/package.json.hbs',
25+
},
26+
{
27+
type: 'add',
28+
path: 'packages/{{kebabCase name}}/src/index.ts',
29+
templateFile: 'templates/sdk/index.ts.hbs',
30+
},
31+
{
32+
type: 'add',
33+
path: 'packages/{{kebabCase name}}/tsconfig.json',
34+
templateFile: 'templates/shared/tsconfig.json.hbs',
35+
},
36+
{
37+
type: 'add',
38+
path: 'packages/{{kebabCase name}}/README.md',
39+
templateFile: 'templates/sdk/README.md.hbs',
40+
},
41+
],
42+
});
43+
44+
// Instrumentation Package Generator
45+
plop.setGenerator('instrumentation', {
46+
description: 'Create a new browser instrumentation package',
47+
prompts: [
48+
{
49+
type: 'input',
50+
name: 'name',
51+
message:
52+
"What API/feature are you instrumenting? (e.g., 'fetch', 'long-task', 'user-interaction')",
53+
},
54+
{
55+
type: 'input',
56+
name: 'description',
57+
message: 'What is the package description?',
58+
},
59+
],
60+
actions: [
61+
{
62+
type: 'add',
63+
path: 'packages/instrumentation-{{kebabCase name}}/package.json',
64+
templateFile: 'templates/instrumentation/package.json.hbs',
65+
},
66+
{
67+
type: 'add',
68+
path: 'packages/instrumentation-{{kebabCase name}}/src/index.ts',
69+
templateFile: 'templates/instrumentation/index.ts.hbs',
70+
},
71+
{
72+
type: 'add',
73+
path: 'packages/instrumentation-{{kebabCase name}}/src/instrumentation.ts',
74+
templateFile: 'templates/instrumentation/instrumentation.ts.hbs',
75+
},
76+
{
77+
type: 'add',
78+
path: 'packages/instrumentation-{{kebabCase name}}/tsconfig.json',
79+
templateFile: 'templates/shared/tsconfig.json.hbs',
80+
},
81+
{
82+
type: 'add',
83+
path: 'packages/instrumentation-{{kebabCase name}}/README.md',
84+
templateFile: 'templates/instrumentation/README.md.hbs',
85+
},
86+
],
87+
});
88+
}

turbo/generators/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "commonjs"
3+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# @opentelemetry/instrumentation-{{kebabCase name}}
2+
3+
{{description}}
4+
5+
## Installation
6+
7+
```bash
8+
npm install @opentelemetry/instrumentation-{{kebabCase name}}
9+
```
10+
11+
## Usage
12+
13+
```typescript
14+
import { {{pascalCase name}}Instrumentation } from '@opentelemetry/instrumentation-{{kebabCase name}}';
15+
import { registerInstrumentations } from '@opentelemetry/instrumentation';
16+
17+
registerInstrumentations({
18+
instrumentations: [
19+
new {{pascalCase name}}Instrumentation({
20+
// configuration options
21+
}),
22+
],
23+
});
24+
```
25+
26+
## Configuration
27+
28+
TODO: Document configuration options
29+
30+
## License
31+
32+
Apache-2.0
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* {{description}}
3+
*
4+
* @packageDocumentation
5+
*/
6+
7+
export { {{pascalCase name}}Instrumentation } from './instrumentation';
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { InstrumentationBase } from '@opentelemetry/instrumentation';
2+
import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
3+
4+
/**
5+
* {{pascalCase name}}Instrumentation Configuration
6+
*/
7+
export interface {{pascalCase name}}InstrumentationConfig extends InstrumentationConfig {
8+
// TODO: Add configuration options
9+
}
10+
11+
/**
12+
* {{description}}
13+
*/
14+
export class {{pascalCase name}}Instrumentation extends InstrumentationBase {
15+
constructor(config: {{pascalCase name}}InstrumentationConfig = {}) {
16+
super('@opentelemetry/instrumentation-{{kebabCase name}}', '0.1.0', config);
17+
}
18+
19+
protected override init() {
20+
// TODO: Implement instrumentation logic
21+
return [];
22+
}
23+
24+
override enable(): void {
25+
// TODO: Implement enable logic
26+
}
27+
28+
override disable(): void {
29+
// TODO: Implement disable logic
30+
}
31+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "@opentelemetry/instrumentation-{{kebabCase name}}",
3+
"version": "0.1.0",
4+
"description": "{{description}}",
5+
"keywords": [
6+
"opentelemetry",
7+
"browser",
8+
"web",
9+
"instrumentation",
10+
"{{kebabCase name}}"
11+
],
12+
"homepage": "https://github.com/open-telemetry/opentelemetry-browser",
13+
"bugs": "https://github.com/open-telemetry/opentelemetry-browser/issues",
14+
"license": "Apache-2.0",
15+
"author": "OpenTelemetry Authors",
16+
"repository": {
17+
"type": "git",
18+
"url": "https://github.com/open-telemetry/opentelemetry-browser.git",
19+
"directory": "packages/instrumentation-{{kebabCase name}}"
20+
},
21+
"type": "module",
22+
"exports": {
23+
".": "./dist/index.js"
24+
},
25+
"files": [
26+
"dist",
27+
"src"
28+
],
29+
"scripts": {
30+
"build": "tsc",
31+
"clean": "node -e \"fs.rmSync('dist', {recursive: true, force: true})\"",
32+
"check-types": "tsc --noEmit"
33+
},
34+
"dependencies": {
35+
"@opentelemetry/api": "*",
36+
"@opentelemetry/core": "*",
37+
"@opentelemetry/instrumentation": "*"
38+
},
39+
"publishConfig": {
40+
"access": "public"
41+
}
42+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# @opentelemetry/{{kebabCase name}}
2+
3+
{{description}}
4+
5+
## Installation
6+
7+
```bash
8+
npm install @opentelemetry/{{kebabCase name}}
9+
```
10+
11+
## Usage
12+
13+
```typescript
14+
// TODO: Add usage example
15+
```
16+
17+
## License
18+
19+
Apache-2.0
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* {{description}}
3+
*
4+
* @packageDocumentation
5+
*/
6+
7+
// TODO: Add exports here
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "@opentelemetry/{{kebabCase name}}",
3+
"version": "0.1.0",
4+
"description": "{{description}}",
5+
"keywords": [
6+
"opentelemetry",
7+
"browser",
8+
"web",
9+
"sdk"
10+
],
11+
"homepage": "https://github.com/open-telemetry/opentelemetry-browser",
12+
"bugs": "https://github.com/open-telemetry/opentelemetry-browser/issues",
13+
"license": "Apache-2.0",
14+
"author": "OpenTelemetry Authors",
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/open-telemetry/opentelemetry-browser.git",
18+
"directory": "packages/{{kebabCase name}}"
19+
},
20+
"type": "module",
21+
"exports": {
22+
".": "./dist/index.js"
23+
},
24+
"files": [
25+
"dist",
26+
"src"
27+
],
28+
"scripts": {
29+
"build": "tsc",
30+
"clean": "node -e \"fs.rmSync('dist', {recursive: true, force: true})\"",
31+
"check-types": "tsc --noEmit"
32+
},
33+
"dependencies": {
34+
"@opentelemetry/api": "*",
35+
"@opentelemetry/core": "*"
36+
},
37+
"publishConfig": {
38+
"access": "public"
39+
}
40+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "./dist",
5+
"rootDir": "./src"
6+
},
7+
"include": ["src/**/*"],
8+
"exclude": ["node_modules", "dist"]
9+
}

0 commit comments

Comments
 (0)