@dagger.io/dagger 0.10.0 → 0.10.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.
Files changed (54) hide show
  1. package/dist/api/client.gen.d.ts +35 -5
  2. package/dist/api/client.gen.d.ts.map +1 -1
  3. package/dist/api/client.gen.js +12 -4
  4. package/dist/api/utils.d.ts.map +1 -1
  5. package/dist/api/utils.js +6 -2
  6. package/dist/common/errors/ExecError.d.ts.map +1 -1
  7. package/dist/entrypoint/context.d.ts +8 -0
  8. package/dist/entrypoint/context.d.ts.map +1 -0
  9. package/dist/entrypoint/invoke.d.ts +3 -9
  10. package/dist/entrypoint/invoke.d.ts.map +1 -1
  11. package/dist/entrypoint/invoke.js +17 -28
  12. package/dist/entrypoint/load.d.ts +29 -69
  13. package/dist/entrypoint/load.d.ts.map +1 -1
  14. package/dist/entrypoint/load.js +90 -173
  15. package/dist/entrypoint/register.d.ts +2 -2
  16. package/dist/entrypoint/register.d.ts.map +1 -1
  17. package/dist/entrypoint/register.js +12 -12
  18. package/dist/introspector/scanner/abtractions/argument.d.ts +75 -0
  19. package/dist/introspector/scanner/abtractions/argument.d.ts.map +1 -0
  20. package/dist/introspector/scanner/abtractions/argument.js +137 -0
  21. package/dist/introspector/scanner/abtractions/constructor.d.ts +16 -0
  22. package/dist/introspector/scanner/abtractions/constructor.d.ts.map +1 -0
  23. package/dist/introspector/scanner/abtractions/constructor.js +42 -0
  24. package/dist/introspector/scanner/abtractions/method.d.ts +51 -0
  25. package/dist/introspector/scanner/abtractions/method.d.ts.map +1 -0
  26. package/dist/introspector/scanner/abtractions/method.js +105 -0
  27. package/dist/introspector/scanner/abtractions/module.d.ts +18 -0
  28. package/dist/introspector/scanner/abtractions/module.d.ts.map +1 -0
  29. package/dist/introspector/scanner/abtractions/module.js +59 -0
  30. package/dist/introspector/scanner/abtractions/object.d.ts +37 -0
  31. package/dist/introspector/scanner/abtractions/object.d.ts.map +1 -0
  32. package/dist/introspector/scanner/abtractions/object.js +94 -0
  33. package/dist/introspector/scanner/abtractions/property.d.ts +46 -0
  34. package/dist/introspector/scanner/abtractions/property.d.ts.map +1 -0
  35. package/dist/introspector/scanner/abtractions/property.js +93 -0
  36. package/dist/introspector/scanner/scan.d.ts +2 -1
  37. package/dist/introspector/scanner/scan.d.ts.map +1 -1
  38. package/dist/introspector/scanner/scan.js +2 -181
  39. package/dist/introspector/scanner/serialize.d.ts +0 -24
  40. package/dist/introspector/scanner/serialize.d.ts.map +1 -1
  41. package/dist/introspector/scanner/serialize.js +0 -53
  42. package/dist/introspector/scanner/typeDefs.d.ts +3 -3
  43. package/dist/introspector/scanner/typeDefs.d.ts.map +1 -1
  44. package/dist/introspector/scanner/utils.d.ts +1 -57
  45. package/dist/introspector/scanner/utils.d.ts.map +1 -1
  46. package/dist/introspector/scanner/utils.js +16 -139
  47. package/dist/provisioning/bin.d.ts.map +1 -1
  48. package/dist/provisioning/bin.js +9 -3
  49. package/dist/provisioning/default.d.ts +1 -1
  50. package/dist/provisioning/default.js +1 -1
  51. package/package.json +6 -5
  52. package/dist/introspector/scanner/metadata.d.ts +0 -24
  53. package/dist/introspector/scanner/metadata.d.ts.map +0 -1
  54. /package/dist/{introspector/scanner/metadata.js → entrypoint/context.js} +0 -0
@@ -1,7 +1,6 @@
1
1
  import ts from "typescript";
2
2
  import { UnknownDaggerError } from "../../common/errors/UnknownDaggerError.js";
3
- import { serializeSignature, serializeSymbol } from "./serialize.js";
4
- import { getAlias, isFunction, isMainObject, isObject, isOptional, isPublicProperty, typeNameToTypedef, } from "./utils.js";
3
+ import { DaggerModule } from "./abtractions/module.js";
5
4
  /**
6
5
  * Scan the list of TypeScript File using the TypeScript compiler API.
7
6
  *
@@ -20,183 +19,5 @@ export function scan(files, moduleName = "") {
20
19
  // Interpret the given typescript source files.
21
20
  const program = ts.createProgram(files, { experimentalDecorators: true });
22
21
  const checker = program.getTypeChecker();
23
- const metadata = {
24
- module: {},
25
- classes: {},
26
- functions: {},
27
- };
28
- for (const file of program.getSourceFiles()) {
29
- // Ignore type declaration files.
30
- if (file.isDeclarationFile) {
31
- continue;
32
- }
33
- ts.forEachChild(file, (node) => {
34
- // Handle class
35
- if (ts.isClassDeclaration(node) && isObject(node)) {
36
- const classTypeDef = introspectClass(checker, node);
37
- if (isMainObject(classTypeDef.name, moduleName)) {
38
- metadata.module.description = introspectTopLevelComment(file);
39
- }
40
- metadata.classes[classTypeDef.name] = classTypeDef;
41
- }
42
- });
43
- }
44
- return metadata;
45
- }
46
- /**
47
- * Introspect a class and return its metadata.
48
- *
49
- * This function goes throw all class' method that have the @fct decorator
50
- * and all its public properties.
51
- *
52
- * This function throws an error if it cannot read its symbol.
53
- *
54
- * @param checker The typescript compiler checker.
55
- * @param node The class to check.
56
- */
57
- function introspectClass(checker, node) {
58
- // Throw error if node.name is undefined because we cannot scan its symbol.
59
- if (!node.name) {
60
- throw new UnknownDaggerError(`could not introspect class: ${node}`, {});
61
- }
62
- // Retrieve class symbol.
63
- const classSymbol = checker.getSymbolAtLocation(node.name);
64
- if (!classSymbol) {
65
- throw new UnknownDaggerError(`could not get class symbol: ${node.name.getText()}`, {});
66
- }
67
- // Serialize class symbol to extract name and doc.
68
- const { name, description } = serializeSymbol(checker, classSymbol);
69
- // Create metadata object.
70
- const metadata = {
71
- name,
72
- description,
73
- constructor: undefined,
74
- fields: {},
75
- methods: {},
76
- };
77
- // Loop through all members in the class to get their metadata.
78
- node.members.forEach((member) => {
79
- // Handle constructor
80
- if (ts.isConstructorDeclaration(member)) {
81
- metadata.constructor = introspectConstructor(checker, member);
82
- }
83
- // Handle method from the class.
84
- if (ts.isMethodDeclaration(member) && isFunction(member)) {
85
- const fctTypeDef = introspectMethod(checker, member);
86
- metadata.methods[fctTypeDef.alias ?? fctTypeDef.name] = fctTypeDef;
87
- }
88
- // Handle public properties from the class.
89
- if (ts.isPropertyDeclaration(member)) {
90
- const fieldTypeDef = introspectProperty(checker, member);
91
- metadata.fields[fieldTypeDef.alias ?? fieldTypeDef.name] = fieldTypeDef;
92
- }
93
- });
94
- return metadata;
95
- }
96
- /**
97
- * Introspect a property from a class and return its metadata.
98
- *
99
- * This function throws an error if it cannot retrieve the property symbols.
100
- *
101
- * @param checker The typescript compiler checker.
102
- * @param property The method to check.
103
- */
104
- function introspectProperty(checker, property) {
105
- const propertySymbol = checker.getSymbolAtLocation(property.name);
106
- if (!propertySymbol) {
107
- throw new UnknownDaggerError(`could not get property symbol: ${property.name.getText()}`, {});
108
- }
109
- const { name, typeName, description } = serializeSymbol(checker, propertySymbol);
110
- return {
111
- name,
112
- description,
113
- alias: getAlias(property, "field"),
114
- typeDef: typeNameToTypedef(typeName),
115
- isExposed: isPublicProperty(property),
116
- };
117
- }
118
- /**
119
- * Introspect the constructor of the class and return its metadata.
120
- */
121
- function introspectConstructor(checker, constructor) {
122
- const args = constructor.parameters.reduce((acc, param) => {
123
- const paramSymbol = checker.getSymbolAtLocation(param.name);
124
- if (!paramSymbol) {
125
- throw new UnknownDaggerError(`could not get constructor param: ${param.name.getText()}`, {});
126
- }
127
- const { name, typeName, description } = serializeSymbol(checker, paramSymbol);
128
- const { optional, defaultValue } = isOptional(paramSymbol);
129
- acc[name] = {
130
- name,
131
- description,
132
- typeDef: typeNameToTypedef(typeName),
133
- optional,
134
- defaultValue,
135
- isVariadic: false,
136
- };
137
- return acc;
138
- }, {});
139
- return { args };
140
- }
141
- /**
142
- * Introspect a method from a class and return its metadata.
143
- *
144
- * This function first retrieve the symbol of the function signature and then
145
- * loop on its parameters to get their metadata.
146
- *
147
- * This function throws an error if it cannot retrieve the method symbols.
148
- *
149
- * @param checker The typescript compiler checker.
150
- * @param method The method to check.
151
- */
152
- function introspectMethod(checker, method) {
153
- const methodSymbol = checker.getSymbolAtLocation(method.name);
154
- if (!methodSymbol) {
155
- throw new UnknownDaggerError(`could not get method symbol: ${method.name.getText()}`, {});
156
- }
157
- const methodMetadata = serializeSymbol(checker, methodSymbol);
158
- const methodSignature = methodMetadata.type
159
- .getCallSignatures()
160
- .map((methodSignature) => serializeSignature(checker, methodSignature))[0];
161
- return {
162
- name: methodMetadata.name,
163
- description: methodMetadata.description,
164
- alias: getAlias(method, "func"),
165
- args: methodSignature.params.reduce((acc, { name, typeName, description, optional, defaultValue, isVariadic }) => {
166
- acc[name] = {
167
- name,
168
- typeDef: typeNameToTypedef(typeName),
169
- description,
170
- optional,
171
- defaultValue,
172
- isVariadic,
173
- };
174
- return acc;
175
- }, {}),
176
- returnType: typeNameToTypedef(methodSignature.returnType),
177
- };
178
- }
179
- /**
180
- * Return the content of the top level comment of the given file.
181
- *
182
- * @param file The file to introspect.
183
- */
184
- function introspectTopLevelComment(file) {
185
- const firstStatement = file.statements[0];
186
- if (!firstStatement) {
187
- return undefined;
188
- }
189
- const commentRanges = ts.getLeadingCommentRanges(file.getFullText(), firstStatement.pos);
190
- if (!commentRanges || commentRanges.length === 0) {
191
- return undefined;
192
- }
193
- const commentRange = commentRanges[0];
194
- const comment = file
195
- .getFullText()
196
- .substring(commentRange.pos, commentRange.end)
197
- .split("\n")
198
- .slice(1, -1) // Remove start and ending comments characters `/** */`
199
- .map((line) => line.replace("*", "").trim()) // Remove leading * and spaces
200
- .join("\n");
201
- return comment;
22
+ return new DaggerModule(checker, moduleName, program.getSourceFiles());
202
23
  }
@@ -1,28 +1,4 @@
1
1
  import ts from "typescript";
2
- import { SignatureMetadata, SymbolMetadata } from "./metadata.js";
3
- /**
4
- * Convert the function signature from the compiler API into a lighter data type.
5
- *
6
- * This functions returns the params serialized and its returns type.
7
- *
8
- * @param checker The typescript compiler checker.
9
- * @param signature The signature to convert.
10
- */
11
- export declare function serializeSignature(checker: ts.TypeChecker, signature: ts.Signature): SignatureMetadata;
12
- /**
13
- * Convert the TypeScript symbol from the compiler API into a lighter data type.
14
- *
15
- * This function returns the name of the symbol, with its typename and its
16
- * documentation.
17
- * This function also returns the actual TypeScript type for additional
18
- * introspection.
19
- *
20
- * @param checker The typescript compiler checker.
21
- * @param symbol The type to convert.
22
- */
23
- export declare function serializeSymbol(checker: ts.TypeChecker, symbol: ts.Symbol): SymbolMetadata & {
24
- type: ts.Type;
25
- };
26
2
  /**
27
3
  * Convert the TypeScript type from the compiler API into a readable textual
28
4
  * type.
@@ -1 +1 @@
1
- {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../introspector/scanner/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAG3B,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAGjE;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,SAAS,EAAE,EAAE,CAAC,SAAS,GACtB,iBAAiB,CAmBnB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,MAAM,EAAE,EAAE,CAAC,MAAM,GAChB,cAAc,GAAG;IAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAA;CAAE,CAkBpC;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM,CAS5E"}
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../../introspector/scanner/serialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,MAAM,CAS5E"}
@@ -1,56 +1,3 @@
1
- import ts from "typescript";
2
- import { UnknownDaggerError } from "../../common/errors/UnknownDaggerError.js";
3
- import { isOptional, isVariadic } from "./utils.js";
4
- /**
5
- * Convert the function signature from the compiler API into a lighter data type.
6
- *
7
- * This functions returns the params serialized and its returns type.
8
- *
9
- * @param checker The typescript compiler checker.
10
- * @param signature The signature to convert.
11
- */
12
- export function serializeSignature(checker, signature) {
13
- return {
14
- params: signature.parameters.map((param) => {
15
- // eslint-disable-next-line prefer-const
16
- let { optional, defaultValue } = isOptional(param);
17
- const variadic = isVariadic(param);
18
- if (variadic) {
19
- optional = true;
20
- }
21
- return {
22
- ...serializeSymbol(checker, param),
23
- optional,
24
- defaultValue,
25
- isVariadic: variadic,
26
- };
27
- }),
28
- returnType: serializeType(checker, signature.getReturnType()),
29
- };
30
- }
31
- /**
32
- * Convert the TypeScript symbol from the compiler API into a lighter data type.
33
- *
34
- * This function returns the name of the symbol, with its typename and its
35
- * documentation.
36
- * This function also returns the actual TypeScript type for additional
37
- * introspection.
38
- *
39
- * @param checker The typescript compiler checker.
40
- * @param symbol The type to convert.
41
- */
42
- export function serializeSymbol(checker, symbol) {
43
- if (!symbol.valueDeclaration) {
44
- throw new UnknownDaggerError("could not find symbol value declaration", {});
45
- }
46
- const type = checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration);
47
- return {
48
- name: symbol.getName(),
49
- description: ts.displayPartsToString(symbol.getDocumentationComment(checker)),
50
- typeName: serializeType(checker, type),
51
- type,
52
- };
53
- }
54
1
  /**
55
2
  * Convert the TypeScript type from the compiler API into a readable textual
56
3
  * type.
@@ -40,7 +40,7 @@ export type FieldTypeDef = {
40
40
  /**
41
41
  * The type of function argument in a method or function.
42
42
  */
43
- export type FunctionArg = {
43
+ export type FunctionArgTypeDef = {
44
44
  name: string;
45
45
  description: string;
46
46
  optional: boolean;
@@ -56,13 +56,13 @@ export type FunctionTypedef = {
56
56
  description: string;
57
57
  alias?: string;
58
58
  args: {
59
- [name: string]: FunctionArg;
59
+ [name: string]: FunctionArgTypeDef;
60
60
  };
61
61
  returnType: TypeDef<TypeDefKind>;
62
62
  };
63
63
  export type ConstructorTypeDef = {
64
64
  args: {
65
- [name: string]: FunctionArg;
65
+ [name: string]: FunctionArgTypeDef;
66
66
  };
67
67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MAAM,GAAG,YAAY,CAAA;KAAE,CAAA;IACxC,WAAW,CAAC,EAAE,kBAAkB,CAAA;IAChC,OAAO,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAA;KAAE,CAAA;CAC7C,CAAA"}
@@ -7,13 +7,7 @@ import { TypeDef } from "./typeDefs.js";
7
7
  * @param object
8
8
  */
9
9
  export declare function isObject(object: ts.ClassDeclaration): boolean;
10
- /**
11
- * Check if the class is the main object of the module.
12
- *
13
- * @param classtName The name of the class to check.
14
- * @param moduleName The name of the module.
15
- */
16
- export declare function isMainObject(className: string, moduleName: string): boolean;
10
+ export declare function toPascalCase(input: string): string;
17
11
  /**
18
12
  * Return true if the given method has the decorator @fct() on top
19
13
  * of its declaration.
@@ -21,58 +15,8 @@ export declare function isMainObject(className: string, moduleName: string): boo
21
15
  * @param method The method to check
22
16
  */
23
17
  export declare function isFunction(method: ts.MethodDeclaration): boolean;
24
- /**
25
- * Return true if the given property has the decorator @field() on top
26
- * of its declaration.
27
- *
28
- * @param property The property to check
29
- */
30
- export declare function isField(property: ts.PropertyDeclaration): boolean;
31
- export declare function getAlias(elem: ts.HasDecorators, kind: "field" | "func"): string | undefined;
32
- /**
33
- * Return true if the given property is public.
34
- *
35
- * This function actually in work the reverse, it checks if the property
36
- * isn't private nor protected.
37
- *
38
- * It returns true if the property has no modifiers since no keyword
39
- * has been set on the property.
40
- *
41
- * Example
42
- * ```
43
- * class Human {
44
- * private age = 22 // Return false
45
- * protected familyName = "Doe" // Return false
46
- *
47
- * @field
48
- * name = "John" // Return true
49
- *
50
- * city = "Paris" // Return false because there's no decorator
51
- * }
52
- * ```
53
- *
54
- * @param property The property to check on.
55
- */
56
- export declare function isPublicProperty(property: ts.PropertyDeclaration): boolean;
57
- type OptionalValue = {
58
- optional: boolean;
59
- defaultValue?: string;
60
- };
61
- /**
62
- * Return true if the parameter is optional.
63
- *
64
- * This includes both optional value defines with `?` and value that
65
- * have a default value.
66
- *
67
- * If there's a default value, its expression is returned in the result.
68
- *
69
- * @param param The param to check.
70
- */
71
- export declare function isOptional(param: ts.Symbol): OptionalValue;
72
- export declare function isVariadic(param: ts.Symbol): boolean;
73
18
  /**
74
19
  * Convert a typename into a Dagger Typedef using dynamic typing.
75
20
  */
76
21
  export declare function typeNameToTypedef(typeName: string): TypeDef<TypeDefKind>;
77
- export {};
78
22
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../introspector/scanner/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,GAAG,OAAO,CAU7D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAwB3E;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,GAAG,OAAO,CAUhE;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,mBAAmB,GAAG,OAAO,CAUjE;AAED,wBAAgB,QAAQ,CACtB,IAAI,EAAE,EAAE,CAAC,aAAa,EACtB,IAAI,EAAE,OAAO,GAAG,MAAM,GACrB,MAAM,GAAG,SAAS,CAsBpB;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,EAAE,CAAC,mBAAmB,GAAG,OAAO,CAe1E;AAED,KAAK,aAAa,GAAG;IACnB,QAAQ,EAAE,OAAO,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,GAAG,aAAa,CAwB1D;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,GAAG,OAAO,CAcpD;AAaD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAyBxE"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../introspector/scanner/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAE3B,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEvC;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAgB,GAAG,OAAO,CAU7D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAoBlD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,iBAAiB,GAAG,OAAO,CAUhE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAyBxE"}
@@ -13,31 +13,22 @@ export function isObject(object) {
13
13
  return false;
14
14
  }) !== undefined);
15
15
  }
16
- /**
17
- * Check if the class is the main object of the module.
18
- *
19
- * @param classtName The name of the class to check.
20
- * @param moduleName The name of the module.
21
- */
22
- export function isMainObject(className, moduleName) {
23
- const toPascalCase = (input) => {
24
- const words = input
25
- .replace(/[^a-zA-Z0-9]/g, " ") // Replace non-alphanumeric characters with spaces
26
- .split(/\s+/)
27
- .filter((word) => word.length > 0);
28
- if (words.length === 0) {
29
- return ""; // No valid words found
30
- }
31
- // It's an edge case when moduleName is already in PascalCase or camelCase
32
- if (words.length === 1) {
33
- return words[0].charAt(0).toUpperCase() + words[0].slice(1);
34
- }
35
- const pascalCase = words
36
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
37
- .join("");
38
- return pascalCase;
39
- };
40
- return toPascalCase(moduleName) === className;
16
+ export function toPascalCase(input) {
17
+ const words = input
18
+ .replace(/[^a-zA-Z0-9]/g, " ") // Replace non-alphanumeric characters with spaces
19
+ .split(/\s+/)
20
+ .filter((word) => word.length > 0);
21
+ if (words.length === 0) {
22
+ return ""; // No valid words found
23
+ }
24
+ // It's an edge case when moduleName is already in PascalCase or camelCase
25
+ if (words.length === 1) {
26
+ return words[0].charAt(0).toUpperCase() + words[0].slice(1);
27
+ }
28
+ const pascalCase = words
29
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
30
+ .join("");
31
+ return pascalCase;
41
32
  }
42
33
  /**
43
34
  * Return true if the given method has the decorator @fct() on top
@@ -53,120 +44,6 @@ export function isFunction(method) {
53
44
  return false;
54
45
  }) !== undefined);
55
46
  }
56
- /**
57
- * Return true if the given property has the decorator @field() on top
58
- * of its declaration.
59
- *
60
- * @param property The property to check
61
- */
62
- export function isField(property) {
63
- return (ts.getDecorators(property)?.find((d) => {
64
- if (ts.isCallExpression(d.expression)) {
65
- return d.expression.expression.getText() === "field";
66
- }
67
- return false;
68
- }) !== undefined);
69
- }
70
- export function getAlias(elem, kind) {
71
- const decorator = ts.getDecorators(elem)?.find((d) => {
72
- if (ts.isCallExpression(d.expression)) {
73
- return d.expression.expression.getText() === kind;
74
- }
75
- return false;
76
- });
77
- if (!decorator) {
78
- return undefined;
79
- }
80
- const expression = decorator.expression;
81
- const args = expression.arguments;
82
- const alias = args[0]?.getText();
83
- if (alias) {
84
- return JSON.parse(alias.replace(/'/g, '"'));
85
- }
86
- return undefined;
87
- }
88
- /**
89
- * Return true if the given property is public.
90
- *
91
- * This function actually in work the reverse, it checks if the property
92
- * isn't private nor protected.
93
- *
94
- * It returns true if the property has no modifiers since no keyword
95
- * has been set on the property.
96
- *
97
- * Example
98
- * ```
99
- * class Human {
100
- * private age = 22 // Return false
101
- * protected familyName = "Doe" // Return false
102
- *
103
- * @field
104
- * name = "John" // Return true
105
- *
106
- * city = "Paris" // Return false because there's no decorator
107
- * }
108
- * ```
109
- *
110
- * @param property The property to check on.
111
- */
112
- export function isPublicProperty(property) {
113
- if (!isField(property)) {
114
- return false;
115
- }
116
- const modifiers = ts.getModifiers(property);
117
- if (!modifiers) {
118
- return true;
119
- }
120
- return !modifiers.some((modifier) => modifier.kind === ts.SyntaxKind.PrivateKeyword ||
121
- modifier.kind === ts.SyntaxKind.ProtectedKeyword);
122
- }
123
- /**
124
- * Return true if the parameter is optional.
125
- *
126
- * This includes both optional value defines with `?` and value that
127
- * have a default value.
128
- *
129
- * If there's a default value, its expression is returned in the result.
130
- *
131
- * @param param The param to check.
132
- */
133
- export function isOptional(param) {
134
- const result = { optional: false };
135
- const declarations = param.getDeclarations();
136
- // Only check if the parameters actually have declarations
137
- if (declarations && declarations.length > 0) {
138
- const parameterDeclaration = declarations[0];
139
- // Convert the symbol declaration into Parameter
140
- if (ts.isParameter(parameterDeclaration)) {
141
- result.optional =
142
- parameterDeclaration.questionToken !== undefined ||
143
- parameterDeclaration.initializer !== undefined;
144
- if (parameterDeclaration.initializer !== undefined) {
145
- result.defaultValue = formatDefaultValue(parameterDeclaration.initializer.getText());
146
- }
147
- }
148
- }
149
- return result;
150
- }
151
- export function isVariadic(param) {
152
- const declarations = param.getDeclarations();
153
- // Only check if the parameters actually have declarations
154
- if (declarations && declarations.length > 0) {
155
- const parameterDeclaration = declarations[0];
156
- // Convert the symbol declaration into Parameter
157
- if (ts.isParameter(parameterDeclaration)) {
158
- return parameterDeclaration.dotDotDotToken !== undefined;
159
- }
160
- }
161
- return false;
162
- }
163
- function formatDefaultValue(value) {
164
- const isSingleQuoteString = () => value.startsWith("'") && value.endsWith("'");
165
- if (isSingleQuoteString()) {
166
- return `"${value.slice(1, value.length - 1)}"`;
167
- }
168
- return value;
169
- }
170
47
  /**
171
48
  * Convert a typename into a Dagger Typedef using dynamic typing.
172
49
  */
@@ -1 +1 @@
1
- {"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../provisioning/bin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAgB/C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAiB,MAAM,iBAAiB,CAAA;AAMxE;;GAEG;AACH,qBAAa,GAAI,YAAW,UAAU;IACpC,OAAO,CAAC,WAAW,CAAC,CAAmB;IAEvC,OAAO,CAAC,OAAO,CAAC,CAAQ;IACxB,OAAO,CAAC,UAAU,CAAC,CAAQ;IAE3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAKxB;IAED,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAW;gBAErC,OAAO,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;IAKjD,IAAI,IAAI,MAAM;IAId,IAAI,UAAU,IAAI,iBAAiB,GAAG,SAAS,CAE9C;IAEK,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;YAgB1C,WAAW;IAgEzB;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAqBrB;;;OAGG;YACW,gBAAgB;YAqEhB,iBAAiB;IA2BzB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAU5B;;;;;;;OAOG;IACH,OAAO,CAAC,cAAc;IAItB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAOpB;;OAEG;IACH,OAAO,CAAC,cAAc;IAWtB;;OAEG;IACH,OAAO,CAAC,cAAc;IAStB;;OAEG;IACH,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,cAAc;YAOR,WAAW;YAkBX,gBAAgB;YAWhB,cAAc;IA4C5B;;OAEG;I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,CAAC,aAAa;IAOrB,OAAO,CAAC,cAAc;YAOR,WAAW;YAkBX,gBAAgB;YAWhB,cAAc;IA4C5B;;OAEG;IACH,OAAO,CAAC,WAAW;CAGpB;AAGD,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAEjD;AAGD,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE1D"}
@@ -68,7 +68,9 @@ export class Bin {
68
68
  }
69
69
  catch (e) {
70
70
  fs.rmSync(tmpBinDownloadDir, { recursive: true });
71
- throw new InitEngineSessionBinaryError(`failed to download dagger cli binary: ${e}`, { cause: e });
71
+ throw new InitEngineSessionBinaryError(`failed to download dagger cli binary: ${e}`, {
72
+ cause: e,
73
+ });
72
74
  }
73
75
  // Remove all temporary binary files
74
76
  // Ignore current dagger cli or other files that have not be
@@ -158,7 +160,9 @@ export class Bin {
158
160
  this.readConnectParams(stdoutReader),
159
161
  new Promise((_, reject) => {
160
162
  setTimeout(() => {
161
- reject(new EngineSessionConnectionTimeoutError("Engine connection timeout", { timeOutDuration }));
163
+ reject(new EngineSessionConnectionTimeoutError("Engine connection timeout", {
164
+ timeOutDuration,
165
+ }));
162
166
  }, timeOutDuration).unref(); // long timeout to account for extensions, though that should be optimized in future
163
167
  }),
164
168
  ]));
@@ -174,7 +178,9 @@ export class Bin {
174
178
  if (connectParams.port && connectParams.session_token) {
175
179
  return connectParams;
176
180
  }
177
- throw new EngineSessionConnectParamsParseError(`invalid connect params: ${line}`, { parsedLine: line });
181
+ throw new EngineSessionConnectParamsParseError(`invalid connect params: ${line}`, {
182
+ parsedLine: line,
183
+ });
178
184
  }
179
185
  // Need to find a better way to handle this part
180
186
  // At this stage something wrong happened, `for await` didn't return anything
@@ -1,2 +1,2 @@
1
- export declare const CLI_VERSION = "0.10.0";
1
+ export declare const CLI_VERSION = "0.10.2";
2
2
  //# sourceMappingURL=default.d.ts.map
@@ -1,2 +1,2 @@
1
1
  // Code generated by dagger. DO NOT EDIT.
2
- export const CLI_VERSION = "0.10.0";
2
+ export const CLI_VERSION = "0.10.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dagger.io/dagger",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "author": "hello@dagger.io",
5
5
  "license": "Apache-2.0",
6
6
  "types": "./dist/index.d.ts",
@@ -12,7 +12,7 @@
12
12
  ".": "./dist/index.js"
13
13
  },
14
14
  "engines": {
15
- "node": ">=16"
15
+ "node": ">=18"
16
16
  },
17
17
  "main": "dist/index.js",
18
18
  "dependencies": {
@@ -33,10 +33,11 @@
33
33
  "build": "tsc",
34
34
  "watch": "tsc -w",
35
35
  "test": "mocha",
36
+ "test:generate-scan": "tsx ./introspector/test/testdata/generate_expected_scan.ts",
36
37
  "lint": "yarn eslint --max-warnings=0 .",
37
38
  "fmt": "yarn eslint --fix .",
38
- "docs:lint": "yarn eslint --max-warnings=0 --resolve-plugins-relative-to=./ --ext=.js,.ts,.mjs,.mts ../../docs/current_docs",
39
- "docs:fmt": "yarn eslint --fix --resolve-plugins-relative-to=./ --ext=.js,.ts,.mjs,.mts ../../docs/current_docs ."
39
+ "docs:lint": "yarn eslint -c .eslintrc-docs.cjs --max-warnings=0 --resolve-plugins-relative-to=./ --ext=.js,.ts,.mjs,.mts ../../docs/current_docs",
40
+ "docs:fmt": "yarn eslint -c .eslintrc-docs.cjs --fix --resolve-plugins-relative-to=./ --ext=.js,.ts,.mjs,.mts ../../docs/current_docs ."
40
41
  },
41
42
  "devDependencies": {
42
43
  "@trivago/prettier-plugin-sort-imports": "^4.2.0",
@@ -46,7 +47,7 @@
46
47
  "@types/tar": "^6.1.4",
47
48
  "@typescript-eslint/eslint-plugin": "^5.62.0",
48
49
  "@typescript-eslint/parser": "^5.62.0",
49
- "eslint": "^8.56.0",
50
+ "eslint": "^8.57.0",
50
51
  "eslint-config-prettier": "^9.1.0",
51
52
  "eslint-plugin-prettier": "^5.1.3",
52
53
  "mocha": "^10.2.0",