feat(build): Added a version stamp in .metadata.json files.

Also modified StaticReflector to handle multiple versions in a
single .metadata.json file.

Fixes #8974
Closes #8981
This commit is contained in:
Chuck Jazdzewski
2016-06-02 16:40:38 -07:00
parent cf2d3cf920
commit 2d8f776e38
4 changed files with 39 additions and 10 deletions

View File

@ -1,7 +1,7 @@
import * as ts from 'typescript';
import {Evaluator, ImportMetadata, ImportSpecifierMetadata, isPrimitive} from './evaluator';
import {ClassMetadata, ConstructorMetadata, ModuleMetadata, MemberMetadata, MetadataError, MetadataMap, MetadataSymbolicExpression, MetadataSymbolicReferenceExpression, MetadataValue, MethodMetadata, isMetadataError, isMetadataSymbolicReferenceExpression,} from './schema';
import {ClassMetadata, ConstructorMetadata, ModuleMetadata, MemberMetadata, MetadataError, MetadataMap, MetadataSymbolicExpression, MetadataSymbolicReferenceExpression, MetadataValue, MethodMetadata, isMetadataError, isMetadataSymbolicReferenceExpression, VERSION} from './schema';
import {Symbols} from './symbols';
/**
@ -207,6 +207,6 @@ export class MetadataCollector {
}
});
return metadata && {__symbolic: 'module', metadata};
return metadata && {__symbolic: 'module', version: VERSION, metadata};
}
}

View File

@ -1,5 +1,17 @@
// Metadata Schema
// If you make a backwards incompatible change to the schema, increment the VERSION number.
// If you make a backwards compatible change to the metadata (such as adding an option field) then
// leave VERSION the same. If possible, as many versions of the metadata that can represent the
// semantics of the file in an array. For example, when generating a version 2 file, if version 1
// can accurately represent the metadata, generate both version 1 and version 2 in an array.
export const VERSION = 1;
export interface ModuleMetadata {
__symbolic: 'module';
version: number;
metadata: {[name: string]: (ClassMetadata | MetadataValue)};
}
export function isModuleMetadata(value: any): value is ModuleMetadata {