@@ -19,8 +19,9 @@ import { SystemUtilities } from './systemUtilities'
19
19
import { normalizeVSCodeUri } from './utilities/vsCodeUtils'
20
20
import { telemetry } from './telemetry/telemetry'
21
21
22
- // Note: this file is currently 12+ MB. When requesting it, specify compression/gzip.
23
- export const samAndCfnSchemaUrl = 'https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json'
22
+ // Note: this file is currently 12+ MB. When requesting it, specify compression/gzip.
23
+ export const samAndCfnSchemaUrl =
24
+ 'https://raw.githubusercontent.com/aws/serverless-application-model/main/samtranslator/schema/schema.json'
24
25
const devfileManifestUrl = 'https://api.github.com/repos/devfile/api/releases/latest'
25
26
const schemaPrefix = `${ AWS_SCHEME } ://`
26
27
@@ -53,15 +54,12 @@ export class SchemaService {
53
54
private schemas ?: Schemas
54
55
private handlers : Map < SchemaType , SchemaHandler >
55
56
56
- public constructor (
57
- private readonly extensionContext : vscode . ExtensionContext ,
58
- opts ?: {
59
- /** Assigned in start(). */
60
- schemas ?: Schemas
61
- updatePeriod ?: number
62
- handlers ?: Map < SchemaType , SchemaHandler >
63
- }
64
- ) {
57
+ public constructor ( opts ?: {
58
+ /** Assigned in start(). */
59
+ schemas ?: Schemas
60
+ updatePeriod ?: number
61
+ handlers ?: Map < SchemaType , SchemaHandler >
62
+ } ) {
65
63
this . updatePeriod = opts ?. updatePeriod ?? SchemaService . defaultUpdatePeriodMillis
66
64
this . schemas = opts ?. schemas
67
65
this . handlers =
@@ -82,7 +80,7 @@ export class SchemaService {
82
80
}
83
81
84
82
public async start ( ) : Promise < void > {
85
- getDefaultSchemas ( this . extensionContext ) . then ( schemas => ( this . schemas = schemas ) )
83
+ getDefaultSchemas ( ) . then ( schemas => ( this . schemas = schemas ) )
86
84
await this . startTimer ( )
87
85
}
88
86
@@ -139,14 +137,13 @@ export class SchemaService {
139
137
* Checks manifest and downloads new schemas if the manifest version has been bumped.
140
138
* Uses local, predownloaded version if up-to-date or network call fails
141
139
* If the user has not previously used the toolkit and cannot pull the manifest, does not provide template autocomplete.
142
- * @param extensionContext VSCode extension context
143
140
*/
144
- export async function getDefaultSchemas ( extensionContext : vscode . ExtensionContext ) : Promise < Schemas | undefined > {
145
- const devfileSchemaUri = vscode . Uri . joinPath ( extensionContext . globalStorageUri , 'devfile.schema.json' )
141
+ export async function getDefaultSchemas ( ) : Promise < Schemas | undefined > {
142
+ const devfileSchemaUri = vscode . Uri . joinPath ( globals . context . globalStorageUri , 'devfile.schema.json' )
146
143
const devfileSchemaVersion = await getPropertyFromJsonUrl ( devfileManifestUrl , 'tag_name' )
147
144
148
145
// Sam schema is a superset of Cfn schema, so we can use it for both
149
- const samAndCfnSchemaDestinationUri = vscode . Uri . joinPath ( extensionContext . globalStorageUri , 'sam.schema.json' )
146
+ const samAndCfnSchemaDestinationUri = vscode . Uri . joinPath ( globals . context . globalStorageUri , 'sam.schema.json' )
150
147
const samAndCfnCacheKey = 'samAndCfnSchemaVersion'
151
148
152
149
const schemas : Schemas = { }
@@ -157,7 +154,7 @@ export async function getDefaultSchemas(extensionContext: vscode.ExtensionContex
157
154
eTag : undefined ,
158
155
url : samAndCfnSchemaUrl ,
159
156
cacheKey : samAndCfnCacheKey ,
160
- extensionContext,
157
+ extensionContext : globals . context ,
161
158
title : schemaPrefix + 'cloudformation.schema.json' ,
162
159
} )
163
160
schemas [ 'cfn' ] = samAndCfnSchemaDestinationUri
@@ -171,7 +168,7 @@ export async function getDefaultSchemas(extensionContext: vscode.ExtensionContex
171
168
eTag : undefined ,
172
169
url : samAndCfnSchemaUrl ,
173
170
cacheKey : samAndCfnCacheKey ,
174
- extensionContext,
171
+ extensionContext : globals . context ,
175
172
title : schemaPrefix + 'sam.schema.json' ,
176
173
} )
177
174
schemas [ 'sam' ] = samAndCfnSchemaDestinationUri
@@ -185,7 +182,7 @@ export async function getDefaultSchemas(extensionContext: vscode.ExtensionContex
185
182
version : devfileSchemaVersion ,
186
183
url : `https://raw.githubusercontent.com/devfile/api/${ devfileSchemaVersion } /schemas/latest/devfile.json` ,
187
184
cacheKey : 'devfileSchemaVersion' ,
188
- extensionContext,
185
+ extensionContext : globals . context ,
189
186
title : schemaPrefix + 'devfile.schema.json' ,
190
187
} )
191
188
schemas [ 'devfile' ] = devfileSchemaUri
0 commit comments