@magicspace/core
Advanced tools
Comparing version 0.2.9 to 0.2.10
/// <reference types="node" /> | ||
import { BinaryFileOptions, JSONFile, JSONFileOptions, TextFile, TextFileOptions } from './@files'; | ||
import { File } from './file'; | ||
export declare function text<TMetadata extends object = object>(content: string | File.ComposeFunction<TextFile>, options?: TextFileOptions): File.Composable<string, TextFileOptions>; | ||
export declare function text<TMetadata extends object = object>(path: string, content: string | File.ComposeFunction<TextFile>, options?: TextFileOptions): File.Composable<string, TextFileOptions>; | ||
export declare function text(path: string, content: string | File.ComposeFunction<TextFile>, options?: TextFileOptions): File.Composable<string, TextFileOptions>; | ||
export declare function text(content: string | File.ComposeFunction<TextFile>, options?: TextFileOptions): File.Composable<string, TextFileOptions>; | ||
export declare function json<TContent>(path: string, value: TContent | File.ComposeFunction<JSONFile<TContent>>, options?: JSONFileOptions): File.Composable<TContent, JSONFileOptions>; | ||
export declare function json<TContent>(value: TContent | File.ComposeFunction<JSONFile<TContent>>, options?: JSONFileOptions): File.Composable<TContent, JSONFileOptions>; | ||
export declare function json<TContent>(path: string, value: TContent | File.ComposeFunction<JSONFile<TContent>>, options?: JSONFileOptions): File.Composable<TContent, JSONFileOptions>; | ||
export interface CopyOptions { | ||
@@ -29,3 +29,3 @@ /** | ||
} | ||
export declare function handlebars<TData>(path: string, data: TData, options?: HandlebarsOptions): File.Composable<string, TextFileOptions>; | ||
export declare function handlebars<TData>(data: TData, options?: HandlebarsOptions): File.Composable<string, TextFileOptions>; | ||
export declare function handlebars<TData>(path: string, data: TData, options?: HandlebarsOptions): File.Composable<string, TextFileOptions>; |
@@ -14,3 +14,3 @@ "use strict"; | ||
let options; | ||
if (typeof args[0] === 'string') { | ||
if (typeof args[1] === 'string' || typeof args[1] === 'function') { | ||
[path, content, options] = args; | ||
@@ -17,0 +17,0 @@ } |
@@ -27,2 +27,3 @@ "use strict"; | ||
await tiva.validate('Magicspace.TemplateOptions', config.options); | ||
await tiva.dispose(); | ||
return config; | ||
@@ -64,2 +65,5 @@ } | ||
} | ||
if (filePatterns && filePatterns.length > 0 && filePathSet.size === 0) { | ||
throw new Error(`No composable module found for patterns ${JSON.stringify(filePatterns)} in template ${JSON.stringify(configFilePath)}`); | ||
} | ||
let fileEntries = Array.from(filePathSet).map((filePath) => { | ||
@@ -92,2 +96,3 @@ return { | ||
}); | ||
console.info(`Resolved template ${JSON.stringify(superDir)}.`); | ||
if (!superDir) { | ||
@@ -94,0 +99,0 @@ throw new Error(`Cannot resolve template ${JSON.stringify(specifier)} specified in ${JSON.stringify(configFilePath)}`); |
@@ -109,3 +109,3 @@ "use strict"; | ||
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires | ||
require(composableModulePath)); | ||
require(composableModulePath)).default; | ||
let composables = typeof moduleDefault === 'function' | ||
@@ -117,2 +117,3 @@ ? await moduleDefault(options, context) | ||
} | ||
console.info(`Loaded composables from ${JSON.stringify(composableModulePath)}.`); | ||
if (!Array.isArray(composables)) { | ||
@@ -119,0 +120,0 @@ composables = [composables]; |
{ | ||
"name": "@magicspace/core", | ||
"version": "0.2.9", | ||
"version": "0.2.10", | ||
"publishConfig": { | ||
@@ -25,3 +25,3 @@ "access": "public" | ||
"sort-keys": "^4.0.0", | ||
"tiva": "^0.2.0", | ||
"tiva": "^0.2.1", | ||
"tslang": "^0.1.22", | ||
@@ -37,3 +37,3 @@ "tslib": "^2.0.1", | ||
}, | ||
"gitHead": "f57e414304b85557119f7fae97cc13a18b205540" | ||
"gitHead": "ba2ffa532a79aafbe57b92e30466a139c6a2d97f" | ||
} |
@@ -17,8 +17,8 @@ import * as FS from 'fs'; | ||
export function text<TMetadata extends object = object>( | ||
export function text( | ||
path: string, | ||
content: string | File.ComposeFunction<TextFile>, | ||
options?: TextFileOptions, | ||
): File.Composable<string, TextFileOptions>; | ||
export function text<TMetadata extends object = object>( | ||
path: string, | ||
export function text( | ||
content: string | File.ComposeFunction<TextFile>, | ||
@@ -32,3 +32,3 @@ options?: TextFileOptions, | ||
if (typeof args[0] === 'string') { | ||
if (typeof args[1] === 'string' || typeof args[1] === 'function') { | ||
[path, content, options] = args; | ||
@@ -56,2 +56,3 @@ } else { | ||
export function json<TContent>( | ||
path: string, | ||
value: TContent | File.ComposeFunction<JSONFile<TContent>>, | ||
@@ -61,3 +62,2 @@ options?: JSONFileOptions, | ||
export function json<TContent>( | ||
path: string, | ||
value: TContent | File.ComposeFunction<JSONFile<TContent>>, | ||
@@ -157,2 +157,3 @@ options?: JSONFileOptions, | ||
export function handlebars<TData>( | ||
path: string, | ||
data: TData, | ||
@@ -162,3 +163,2 @@ options?: HandlebarsOptions, | ||
export function handlebars<TData>( | ||
path: string, | ||
data: TData, | ||
@@ -165,0 +165,0 @@ options?: HandlebarsOptions, |
@@ -58,2 +58,4 @@ import * as FS from 'fs'; | ||
await tiva.dispose(); | ||
return config; | ||
@@ -115,2 +117,10 @@ } | ||
if (filePatterns && filePatterns.length > 0 && filePathSet.size === 0) { | ||
throw new Error( | ||
`No composable module found for patterns ${JSON.stringify( | ||
filePatterns, | ||
)} in template ${JSON.stringify(configFilePath)}`, | ||
); | ||
} | ||
let fileEntries = Array.from(filePathSet).map( | ||
@@ -158,2 +168,4 @@ (filePath): ComposableFileEntry => { | ||
console.info(`Resolved template ${JSON.stringify(superDir)}.`); | ||
if (!superDir) { | ||
@@ -160,0 +172,0 @@ throw new Error( |
@@ -179,3 +179,3 @@ import * as Path from 'path'; | ||
require(composableModulePath), | ||
) as ComposableModuleDefault; | ||
).default as ComposableModuleDefault; | ||
@@ -191,2 +191,6 @@ let composables = | ||
console.info( | ||
`Loaded composables from ${JSON.stringify(composableModulePath)}.`, | ||
); | ||
if (!Array.isArray(composables)) { | ||
@@ -193,0 +197,0 @@ composables = [composables]; |
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
118405
2482
Updatedtiva@^0.2.1