@azure-tools/codegen
Advanced tools
Comparing version 2.0.185 to 2.1.191
@@ -12,2 +12,3 @@ export * from './exec'; | ||
export * from './safe-eval'; | ||
export * from './source-track'; | ||
//# sourceMappingURL=exports.d.ts.map |
@@ -17,2 +17,3 @@ "use strict"; | ||
__export(require("./safe-eval")); | ||
__export(require("./source-track")); | ||
//# sourceMappingURL=exports.js.map |
@@ -6,5 +6,5 @@ export declare type DeepPartial<T> = { | ||
export declare class Initializer { | ||
private applyTo; | ||
protected apply<T>(initializer?: Partial<T>): void; | ||
protected apply<T>(...initializer: Array<DeepPartial<T> | undefined>): void; | ||
protected applyTo<T>($this: T, ...initializer: Array<DeepPartial<T> | undefined>): void; | ||
} | ||
//# sourceMappingURL=initializer.d.ts.map |
@@ -8,31 +8,60 @@ "use strict"; | ||
const linq_1 = require("@azure-tools/linq"); | ||
/** inheriting from Initializer adds an apply<T> method to the class, allowing you to accept an object initalizer, and applying it to the class in the constructor. */ | ||
class Initializer { | ||
applyTo(source, target) { | ||
for (const i of linq_1.keys(source)) { | ||
switch (typeof source[i]) { | ||
// case 'function': | ||
// don't copy functions. | ||
// continue; | ||
case 'object': | ||
// merge objects | ||
if (source[i] != null && source[i] != undefined && typeof target[i] === 'object') { | ||
this.applyTo(source[i], target[i]); | ||
continue; | ||
} | ||
// fall thru | ||
default: | ||
// everything else just replace. | ||
target[i] = source[i]; | ||
function applyTo(source, target, cache = new Set()) { | ||
if (cache.has(source)) { | ||
throw new Error('Circular refrenced models are not permitted in apply() initializers.'); | ||
} | ||
for (const i of linq_1.keys(source)) { | ||
switch (typeof source[i]) { | ||
case 'object': | ||
// merge objects | ||
if (source[i] != null && source[i] != undefined && typeof target[i] === 'object') { | ||
cache.add(source); | ||
applyTo(source[i], target[i], cache); | ||
cache.delete(source); | ||
continue; | ||
} | ||
// otherwise, just use that object. | ||
target[i] = source[i]; | ||
continue; | ||
/* bad idea? : | ||
this recursively cloned the contents of the intializer | ||
but this has the effect of breaking referencs where I wanted | ||
them. | ||
// copy toarray | ||
if (Array.isArray(source[i])) { | ||
cache.add(source); | ||
applyTo(source[i], target[i] = [], cache); | ||
cache.delete(source); | ||
continue; | ||
} | ||
// otherwise, copy into an empty object | ||
cache.add(source); | ||
applyTo(source[i], target[i] = {}, cache); | ||
cache.delete(source); | ||
continue; | ||
*/ | ||
default: | ||
// everything else just replace. | ||
target[i] = source[i]; | ||
continue; | ||
} | ||
} | ||
apply(initializer) { | ||
if (initializer) { | ||
this.applyTo(initializer, this); | ||
} | ||
/** inheriting from Initializer adds an apply<T> method to the class, allowing you to accept an object initalizer, and applying it to the class in the constructor. */ | ||
class Initializer { | ||
apply(...initializer) { | ||
for (const each of initializer) { | ||
applyTo(each, this); | ||
} | ||
} | ||
applyTo($this, ...initializer) { | ||
for (const each of initializer) { | ||
applyTo(each, $this); | ||
} | ||
} | ||
} | ||
exports.Initializer = Initializer; | ||
//# sourceMappingURL=initializer.js.map |
@@ -241,3 +241,3 @@ "use strict"; | ||
function pascalCase(identifier) { | ||
return typeof identifier === 'string' ? | ||
return identifier === undefined ? '' : typeof identifier === 'string' ? | ||
pascalCase(fixLeadingNumber(deconstruct(identifier))) : | ||
@@ -244,0 +244,0 @@ [...removeSequentialDuplicates(identifier)].map(each => each.capitalize()).join(''); |
@@ -9,2 +9,4 @@ "use strict"; | ||
const propertyPriority = [ | ||
'$key', | ||
'name', | ||
'schemas', | ||
@@ -18,3 +20,4 @@ 'name', | ||
'method', | ||
'description' | ||
'description', | ||
'default', | ||
]; | ||
@@ -27,3 +30,5 @@ const propertyNegativePriority = [ | ||
'extensions', | ||
'details' | ||
'details', | ||
'language', | ||
'protocol' | ||
]; | ||
@@ -71,5 +76,15 @@ function sortWithPriorty(a, b) { | ||
function serialize(model) { | ||
return js_yaml_1.dump(model, { sortKeys: sortWithPriorty, schema: js_yaml_1.DEFAULT_SAFE_SCHEMA, skipInvalid: true, lineWidth: 240 }); | ||
return js_yaml_1.dump(model, { | ||
sortKeys: sortWithPriorty, | ||
schema: js_yaml_1.DEFAULT_SAFE_SCHEMA, | ||
skipInvalid: true, | ||
lineWidth: 240 | ||
}). | ||
replace(/\s*\w*: {}/g, ''). | ||
replace(/\s*\w*: \[\]/g, ''). | ||
replace(/(\s*- \$key:)/g, '\n$1'). | ||
replace(/(\s*)(language:)/g, '\n$1## ----------------------------------------------------------------------$1$2'); | ||
//.replace(/(\s*language:)/g, '\n$1'); | ||
} | ||
exports.serialize = serialize; | ||
//# sourceMappingURL=yaml.js.map |
{ | ||
"name": "@azure-tools/codegen", | ||
"version": "2.0.185", | ||
"version": "2.1.191", | ||
"patchOffset": 100, | ||
@@ -24,3 +24,3 @@ "description": "Autorest Code generator common and base classes", | ||
"type": "git", | ||
"url": "git+https://github.com/Azure/autorest.powershell.git" | ||
"url": "git+https://github.com/Azure/perks.git" | ||
}, | ||
@@ -34,3 +34,3 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/Azure/autorest.powershell/issues" | ||
"url": "https://github.com/Azure/perks/issues" | ||
}, | ||
@@ -49,7 +49,8 @@ "homepage": "https://github.com/Azure/perks/tree/master/codegen#readme", | ||
"eslint": "~6.2.2", | ||
"@types/semver": "5.5.0" | ||
"@types/semver": "5.5.0", | ||
"source-map-support": "0.5.13" | ||
}, | ||
"dependencies": { | ||
"@azure-tools/async-io": "~3.0.184", | ||
"@azure-tools/linq": "~3.0.185", | ||
"@azure-tools/async-io": "~3.0.185", | ||
"@azure-tools/linq": "~3.1.187", | ||
"js-yaml": "3.13.1", | ||
@@ -56,0 +57,0 @@ "semver": "^5.5.1", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
178337
60
2272
11
+ Added@azure-tools/linq@3.1.263(transitive)
- Removed@azure-tools/linq@3.0.185(transitive)
Updated@azure-tools/linq@~3.1.187