@typespec/compiler 1.15.0-dev.4 → 1.15.0-dev.6
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.
- package/dist/manifest.js +2 -2
- package/dist/src/core/cli/cli.d.ts +1 -11
- package/dist/src/core/cli/cli.d.ts.map +1 -1
- package/dist/src/core/cli/cli.js +12 -35
- package/dist/src/core/cli/cli.js.map +1 -1
- package/dist/src/core/cli/utils.d.ts +4 -4
- package/dist/src/core/cli/utils.d.ts.map +1 -1
- package/dist/src/core/cli/utils.js +6 -6
- package/dist/src/core/cli/utils.js.map +1 -1
- package/dist/src/core/file-ref.d.ts +26 -0
- package/dist/src/core/file-ref.d.ts.map +1 -0
- package/dist/src/core/file-ref.js +19 -0
- package/dist/src/core/file-ref.js.map +1 -0
- package/dist/src/core/types.d.ts +13 -0
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/core/types.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/init/core-templates.d.ts +2 -2
- package/dist/src/init/core-templates.d.ts.map +1 -1
- package/dist/src/init/core-templates.js +3 -10
- package/dist/src/init/core-templates.js.map +1 -1
- package/dist/src/init/init.d.ts +8 -7
- package/dist/src/init/init.d.ts.map +1 -1
- package/dist/src/init/init.js +35 -44
- package/dist/src/init/init.js.map +1 -1
- package/dist/src/init/scaffold.d.ts +4 -2
- package/dist/src/init/scaffold.d.ts.map +1 -1
- package/dist/src/init/scaffold.js +4 -4
- package/dist/src/init/scaffold.js.map +1 -1
- package/dist/src/init/template-source/default-core-templates.d.ts +9 -0
- package/dist/src/init/template-source/default-core-templates.d.ts.map +1 -0
- package/dist/src/init/template-source/default-core-templates.js +12 -0
- package/dist/src/init/template-source/default-core-templates.js.map +1 -0
- package/dist/src/init/template-source/in-memory-template-source.d.ts +19 -0
- package/dist/src/init/template-source/in-memory-template-source.d.ts.map +1 -0
- package/dist/src/init/template-source/in-memory-template-source.js +45 -0
- package/dist/src/init/template-source/in-memory-template-source.js.map +1 -0
- package/dist/src/init/template-source/index.d.ts +5 -0
- package/dist/src/init/template-source/index.d.ts.map +1 -0
- package/dist/src/init/template-source/index.js +4 -0
- package/dist/src/init/template-source/index.js.map +1 -0
- package/dist/src/init/template-source/types.d.ts +21 -0
- package/dist/src/init/template-source/types.d.ts.map +1 -0
- package/dist/src/init/template-source/types.js +2 -0
- package/dist/src/init/template-source/types.js.map +1 -0
- package/dist/src/init/template-source/uri-template-source.d.ts +30 -0
- package/dist/src/init/template-source/uri-template-source.d.ts.map +1 -0
- package/dist/src/init/template-source/uri-template-source.js +45 -0
- package/dist/src/init/template-source/uri-template-source.js.map +1 -0
- package/dist/src/internals/index.d.ts +2 -0
- package/dist/src/internals/index.d.ts.map +1 -1
- package/dist/src/internals/index.js +1 -0
- package/dist/src/internals/index.js.map +1 -1
- package/entrypoints/cli.js +1 -3
- package/package.json +2 -6
- package/dist/src/internals/standalone.d.ts +0 -13
- package/dist/src/internals/standalone.d.ts.map +0 -1
- package/dist/src/internals/standalone.js +0 -13
- package/dist/src/internals/standalone.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/init/template-source/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,qGAAqG;AACrG,MAAM,WAAW,mBAAmB;IAClC,mCAAmC;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACjD,sFAAsF;IACtF,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAC/B,wFAAwF;IACxF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC1C,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/init/template-source/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { SourceFile, SystemHost } from "../../core/types.js";
|
|
2
|
+
import type { LoadedTemplateIndex, TemplateSource } from "./types.js";
|
|
3
|
+
/** File name of the template index within a template source directory. */
|
|
4
|
+
export declare const SCAFFOLDING_FILENAME = "scaffolding.json";
|
|
5
|
+
/**
|
|
6
|
+
* A {@link TemplateSource} backed by a location: a filesystem path or a URL. The index and every
|
|
7
|
+
* template file are read through a {@link SystemHost} via {@link readUrlOrPath}, so this handles both
|
|
8
|
+
* a local directory and a remote `tsp init <url>` uniformly. Built-in templates are served through
|
|
9
|
+
* {@link defaultInternalTemplateSource} (or an injected provider) instead.
|
|
10
|
+
*
|
|
11
|
+
* Loading an untrusted remote template can execute arbitrary code during scaffolding; callers are
|
|
12
|
+
* responsible for confirming the source with the user before using it.
|
|
13
|
+
*/
|
|
14
|
+
export declare class UriTemplateSource implements TemplateSource {
|
|
15
|
+
#private;
|
|
16
|
+
/**
|
|
17
|
+
* @param host Host used to read the index and template files.
|
|
18
|
+
* @param indexLocation Location of the index file (a path or URL). Template files are resolved
|
|
19
|
+
* relative to its containing directory.
|
|
20
|
+
*/
|
|
21
|
+
constructor(host: SystemHost, indexLocation: string);
|
|
22
|
+
/**
|
|
23
|
+
* Create a source for a template root directory (path or URL) whose index is a
|
|
24
|
+
* `scaffolding.json` at its root.
|
|
25
|
+
*/
|
|
26
|
+
static fromDirectory(host: SystemHost, directory: string): UriTemplateSource;
|
|
27
|
+
loadIndex(): Promise<LoadedTemplateIndex>;
|
|
28
|
+
readFile(relativePath: string): Promise<SourceFile>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=uri-template-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uri-template-source.d.ts","sourceRoot":"","sources":["../../../../src/init/template-source/uri-template-source.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEtE,0EAA0E;AAC1E,eAAO,MAAM,oBAAoB,qBAAqB,CAAC;AAEvD;;;;;;;;GAQG;AACH,qBAAa,iBAAkB,YAAW,cAAc;;IAMtD;;;;OAIG;gBACS,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM;IAMnD;;;OAGG;IACH,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB;IAOtE,SAAS,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAMzC,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAG1D"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { getDirectoryPath } from "../../core/path-utils.js";
|
|
2
|
+
import { readUrlOrPath, resolveRelativeUrlOrPath } from "../../utils/misc.js";
|
|
3
|
+
/** File name of the template index within a template source directory. */
|
|
4
|
+
export const SCAFFOLDING_FILENAME = "scaffolding.json";
|
|
5
|
+
/**
|
|
6
|
+
* A {@link TemplateSource} backed by a location: a filesystem path or a URL. The index and every
|
|
7
|
+
* template file are read through a {@link SystemHost} via {@link readUrlOrPath}, so this handles both
|
|
8
|
+
* a local directory and a remote `tsp init <url>` uniformly. Built-in templates are served through
|
|
9
|
+
* {@link defaultInternalTemplateSource} (or an injected provider) instead.
|
|
10
|
+
*
|
|
11
|
+
* Loading an untrusted remote template can execute arbitrary code during scaffolding; callers are
|
|
12
|
+
* responsible for confirming the source with the user before using it.
|
|
13
|
+
*/
|
|
14
|
+
export class UriTemplateSource {
|
|
15
|
+
#host;
|
|
16
|
+
#indexLocation;
|
|
17
|
+
/** Directory (path or URL) that template file paths are resolved against. */
|
|
18
|
+
#baseUri;
|
|
19
|
+
/**
|
|
20
|
+
* @param host Host used to read the index and template files.
|
|
21
|
+
* @param indexLocation Location of the index file (a path or URL). Template files are resolved
|
|
22
|
+
* relative to its containing directory.
|
|
23
|
+
*/
|
|
24
|
+
constructor(host, indexLocation) {
|
|
25
|
+
this.#host = host;
|
|
26
|
+
this.#indexLocation = indexLocation;
|
|
27
|
+
this.#baseUri = getDirectoryPath(indexLocation);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a source for a template root directory (path or URL) whose index is a
|
|
31
|
+
* `scaffolding.json` at its root.
|
|
32
|
+
*/
|
|
33
|
+
static fromDirectory(host, directory) {
|
|
34
|
+
return new UriTemplateSource(host, resolveRelativeUrlOrPath(directory + "/", SCAFFOLDING_FILENAME));
|
|
35
|
+
}
|
|
36
|
+
async loadIndex() {
|
|
37
|
+
const indexFile = await readUrlOrPath(this.#host, this.#indexLocation);
|
|
38
|
+
const templates = JSON.parse(indexFile.text);
|
|
39
|
+
return { templates, indexFile, baseUri: this.#baseUri };
|
|
40
|
+
}
|
|
41
|
+
async readFile(relativePath) {
|
|
42
|
+
return readUrlOrPath(this.#host, resolveRelativeUrlOrPath(this.#baseUri + "/", relativePath));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=uri-template-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uri-template-source.js","sourceRoot":"","sources":["../../../../src/init/template-source/uri-template-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAG9E,0EAA0E;AAC1E,MAAM,CAAC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAEvD;;;;;;;;GAQG;AACH,MAAM,OAAO,iBAAiB;IAC5B,KAAK,CAAa;IAClB,cAAc,CAAS;IACvB,6EAA6E;IAC7E,QAAQ,CAAS;IAEjB;;;;OAIG;IACH,YAAY,IAAgB,EAAE,aAAqB;QACjD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,cAAc,GAAG,aAAa,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAAC;IAClD,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,aAAa,CAAC,IAAgB,EAAE,SAAiB;QACtD,OAAO,IAAI,iBAAiB,CAC1B,IAAI,EACJ,wBAAwB,CAAC,SAAS,GAAG,GAAG,EAAE,oBAAoB,CAAC,CAChE,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,SAAS;QACb,MAAM,SAAS,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QACvE,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,YAAoB;QACjC,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,wBAAwB,CAAC,IAAI,CAAC,QAAQ,GAAG,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;IAChG,CAAC;CACF"}
|
|
@@ -6,6 +6,8 @@ export { resolveCompilerOptions } from "../config/config-to-options.js";
|
|
|
6
6
|
export { NodeSystemHost } from "../core/node-system-host.js";
|
|
7
7
|
export { InitTemplateSchema } from "../init/init-template.js";
|
|
8
8
|
export { makeScaffoldingConfig, scaffoldNewProject } from "../init/scaffold.js";
|
|
9
|
+
export type { TemplateSource } from "../init/template-source/types.js";
|
|
10
|
+
export { UriTemplateSource } from "../init/template-source/uri-template-source.js";
|
|
9
11
|
export { resolveEntrypointFile } from "../server/entrypoint-resolver.js";
|
|
10
12
|
export { InternalCompileResult, ServerDiagnostic } from "../server/index.js";
|
|
11
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/internals/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/internals/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEhF,YAAY,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -9,5 +9,6 @@ export { resolveCompilerOptions } from "../config/config-to-options.js";
|
|
|
9
9
|
export { NodeSystemHost } from "../core/node-system-host.js";
|
|
10
10
|
export { InitTemplateSchema } from "../init/init-template.js";
|
|
11
11
|
export { makeScaffoldingConfig, scaffoldNewProject } from "../init/scaffold.js";
|
|
12
|
+
export { UriTemplateSource } from "../init/template-source/uri-template-source.js";
|
|
12
13
|
export { resolveEntrypointFile } from "../server/entrypoint-resolver.js";
|
|
13
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/internals/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,IAAI,CAAE,UAAkB,CAAC,6BAA6B,EAAE,CAAC;IACvD,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;AAC/F,CAAC;AAED,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/internals/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,IAAI,CAAE,UAAkB,CAAC,6BAA6B,EAAE,CAAC;IACvD,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;AAC/F,CAAC;AAED,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGhF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC"}
|
package/entrypoints/cli.js
CHANGED
|
@@ -2,6 +2,4 @@
|
|
|
2
2
|
* File serving as an entrypoint to resolve a local tsp install from a global install.
|
|
3
3
|
* DO NOT MOVE or this will create a breaking change for user of global cli.
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
await runTypeSpecCli();
|
|
5
|
+
import "../dist/src/core/cli/cli.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/compiler",
|
|
3
|
-
"version": "1.15.0-dev.
|
|
3
|
+
"version": "1.15.0-dev.6",
|
|
4
4
|
"description": "TypeSpec compiler and standard library",
|
|
5
5
|
"author": "Microsoft Corporation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -60,13 +60,9 @@
|
|
|
60
60
|
"./internals/prettier-formatter": {
|
|
61
61
|
"import": "./dist/src/internals/prettier-formatter.js"
|
|
62
62
|
},
|
|
63
|
-
"./internals/standalone": {
|
|
64
|
-
"import": "./dist/src/internals/standalone.js"
|
|
65
|
-
},
|
|
66
63
|
"./casing": {
|
|
67
64
|
"import": "./dist/src/casing/index.js"
|
|
68
|
-
}
|
|
69
|
-
"./package.json": "./package.json"
|
|
65
|
+
}
|
|
70
66
|
},
|
|
71
67
|
"browser": {
|
|
72
68
|
"./dist/src/core/node-host.js": "./dist/src/core/node-host.browser.js",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal API used to build a self-contained ("standalone") TypeSpec CLI that bundles the compiler
|
|
3
|
-
* into a single executable.
|
|
4
|
-
*
|
|
5
|
-
* This is a separate entrypoint from `@typespec/compiler/internals` on purpose: `runTypeSpecCli`
|
|
6
|
-
* reaches into the CLI runner, which transitively loads `node-host` (top-level `await`) and Node
|
|
7
|
-
* built-ins. Keeping it out of the general `internals` barrel avoids forcing those onto every
|
|
8
|
-
* browser/CommonJS consumer of `internals` (e.g. the VS Code extension and the playground).
|
|
9
|
-
*
|
|
10
|
-
* DO NOT USE. Not part of the public API and may change at any time with no warning.
|
|
11
|
-
*/
|
|
12
|
-
export { runTypeSpecCli } from "../core/cli/cli.js";
|
|
13
|
-
//# sourceMappingURL=standalone.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standalone.d.ts","sourceRoot":"","sources":["../../../src/internals/standalone.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal API used to build a self-contained ("standalone") TypeSpec CLI that bundles the compiler
|
|
3
|
-
* into a single executable.
|
|
4
|
-
*
|
|
5
|
-
* This is a separate entrypoint from `@typespec/compiler/internals` on purpose: `runTypeSpecCli`
|
|
6
|
-
* reaches into the CLI runner, which transitively loads `node-host` (top-level `await`) and Node
|
|
7
|
-
* built-ins. Keeping it out of the general `internals` barrel avoids forcing those onto every
|
|
8
|
-
* browser/CommonJS consumer of `internals` (e.g. the VS Code extension and the playground).
|
|
9
|
-
*
|
|
10
|
-
* DO NOT USE. Not part of the public API and may change at any time with no warning.
|
|
11
|
-
*/
|
|
12
|
-
export { runTypeSpecCli } from "../core/cli/cli.js";
|
|
13
|
-
//# sourceMappingURL=standalone.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standalone.js","sourceRoot":"","sources":["../../../src/internals/standalone.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC"}
|