@expo/template-file 1.0.221 → 1.0.260

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/index.d.ts CHANGED
@@ -1,2 +1,9 @@
1
- import templateFile from './templateFile';
2
- export = templateFile;
1
+ export declare function templateString({ input, vars, mustache, }: {
2
+ input: string;
3
+ vars: Record<string, unknown>;
4
+ mustache?: boolean;
5
+ }): string;
6
+ export declare function templateFile(templateFilePath: string, vars: Record<string, unknown>, outputFilePath?: string, options?: {
7
+ mustache?: boolean;
8
+ }): Promise<string | void>;
9
+ export default templateFile;
package/dist/index.js CHANGED
@@ -2,6 +2,29 @@
2
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
- const templateFile_1 = __importDefault(require("./templateFile"));
6
- module.exports = templateFile_1.default;
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.templateString = templateString;
7
+ exports.templateFile = templateFile;
8
+ const promises_1 = __importDefault(require("fs/promises"));
9
+ // We can't use lodash/template because templates expect to be able to do `_.forEach`.
10
+ const lodash_1 = __importDefault(require("lodash"));
11
+ function templateString({ input, vars, mustache = true, }) {
12
+ const compiledTemplate = lodash_1.default.template(input, mustache
13
+ ? {
14
+ interpolate: /{{([\s\S]+?)}}/g,
15
+ }
16
+ : undefined);
17
+ return compiledTemplate(vars);
18
+ }
19
+ async function templateFile(templateFilePath, vars, outputFilePath, options = {}) {
20
+ const templateContent = await promises_1.default.readFile(templateFilePath, 'utf8');
21
+ const outputFileContents = templateString({ input: templateContent, vars, ...options });
22
+ if (outputFilePath) {
23
+ await promises_1.default.writeFile(outputFilePath, outputFileContents);
24
+ }
25
+ else {
26
+ return outputFileContents;
27
+ }
28
+ }
29
+ exports.default = templateFile;
7
30
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,kEAA0C;AAE1C,iBAAS,sBAAY,CAAC","sourcesContent":["import templateFile from './templateFile';\n\nexport = templateFile;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAKA,wCAkBC;AAED,oCAcC;AAvCD,2DAA6B;AAE7B,sFAAsF;AACtF,oDAAuB;AAEvB,SAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,IAAI,EACJ,QAAQ,GAAG,IAAI,GAKhB;IACC,MAAM,gBAAgB,GAAG,gBAAC,CAAC,QAAQ,CACjC,KAAK,EACL,QAAQ;QACN,CAAC,CAAC;YACE,WAAW,EAAE,iBAAiB;SAC/B;QACH,CAAC,CAAC,SAAS,CACd,CAAC;IACF,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC;AAEM,KAAK,UAAU,YAAY,CAChC,gBAAwB,EACxB,IAA6B,EAC7B,cAAuB,EACvB,UAAkC,EAAE;IAEpC,MAAM,eAAe,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IACpE,MAAM,kBAAkB,GAAG,cAAc,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAExF,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,kBAAE,CAAC,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;IACzD,CAAC;SAAM,CAAC;QACN,OAAO,kBAAkB,CAAC;IAC5B,CAAC;AACH,CAAC;AAED,kBAAe,YAAY,CAAC","sourcesContent":["import fs from 'fs/promises';\n\n// We can't use lodash/template because templates expect to be able to do `_.forEach`.\nimport _ from 'lodash';\n\nexport function templateString({\n input,\n vars,\n mustache = true,\n}: {\n input: string;\n vars: Record<string, unknown>;\n mustache?: boolean;\n}): string {\n const compiledTemplate = _.template(\n input,\n mustache\n ? {\n interpolate: /{{([\\s\\S]+?)}}/g,\n }\n : undefined\n );\n return compiledTemplate(vars);\n}\n\nexport async function templateFile(\n templateFilePath: string,\n vars: Record<string, unknown>,\n outputFilePath?: string,\n options: { mustache?: boolean } = {}\n): Promise<string | void> {\n const templateContent = await fs.readFile(templateFilePath, 'utf8');\n const outputFileContents = templateString({ input: templateContent, vars, ...options });\n\n if (outputFilePath) {\n await fs.writeFile(outputFilePath, outputFileContents);\n } else {\n return outputFileContents;\n }\n}\n\nexport default templateFile;\n"]}
package/package.json CHANGED
@@ -1,6 +1,11 @@
1
1
  {
2
2
  "name": "@expo/template-file",
3
- "version": "1.0.221",
3
+ "repository": {
4
+ "type": "git",
5
+ "url": "https://github.com/expo/eas-build.git",
6
+ "directory": "packages/template-file"
7
+ },
8
+ "version": "1.0.260",
4
9
  "main": "dist/index.js",
5
10
  "types": "dist/index.d.ts",
6
11
  "files": [
@@ -19,11 +24,9 @@
19
24
  "bugs": "https://github.com/expo/eas-build/issues",
20
25
  "license": "BUSL-1.1",
21
26
  "dependencies": {
22
- "fs-extra": "^11.2.0",
23
27
  "lodash": "^4.17.21"
24
28
  },
25
29
  "devDependencies": {
26
- "@types/fs-extra": "^11.0.4",
27
30
  "@types/jest": "^29.5.12",
28
31
  "@types/lodash": "^4.17.4",
29
32
  "@types/lodash.template": "^4.5.3",
@@ -36,5 +39,5 @@
36
39
  "node": "20.14.0",
37
40
  "yarn": "1.22.21"
38
41
  },
39
- "gitHead": "d199b9a2d4852d1711374e7db54e3ffdcad4edb4"
42
+ "gitHead": "86661f158977836b1cfd9643a690fc816a4f44e4"
40
43
  }
@@ -1,4 +0,0 @@
1
- declare function templateFile(templateFilePath: string, envs: Record<string, string | number | any>, outputFilePath?: string, { mustache }?: {
2
- mustache?: boolean;
3
- }): Promise<string | void>;
4
- export default templateFile;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const lodash_1 = __importDefault(require("lodash"));
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- async function templateFile(templateFilePath, envs, outputFilePath, { mustache = true } = {}) {
9
- const templateString = await fs_extra_1.default.readFile(templateFilePath, 'utf8');
10
- const compiledTemplate = lodash_1.default.template(templateString, mustache
11
- ? {
12
- // mustache
13
- interpolate: /{{([\s\S]+?)}}/g,
14
- }
15
- : undefined);
16
- const outputFileContents = compiledTemplate(envs);
17
- if (outputFilePath) {
18
- await fs_extra_1.default.writeFile(outputFilePath, outputFileContents);
19
- }
20
- else {
21
- return outputFileContents;
22
- }
23
- }
24
- exports.default = templateFile;
25
- //# sourceMappingURL=templateFile.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"templateFile.js","sourceRoot":"","sources":["../src/templateFile.ts"],"names":[],"mappings":";;;;;AAAA,oDAAuB;AACvB,wDAA0B;AAE1B,KAAK,UAAU,YAAY,CACzB,gBAAwB,EACxB,IAA2C,EAC3C,cAAuB,EACvB,EAAE,QAAQ,GAAG,IAAI,KAA6B,EAAE;IAEhD,MAAM,cAAc,GAAG,MAAM,kBAAE,CAAC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IACnE,MAAM,gBAAgB,GAAG,gBAAC,CAAC,QAAQ,CACjC,cAAc,EACd,QAAQ;QACN,CAAC,CAAC;YACE,WAAW;YACX,WAAW,EAAE,iBAAiB;SAC/B;QACH,CAAC,CAAC,SAAS,CACd,CAAC;IACF,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAElD,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,kBAAE,CAAC,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;IACzD,CAAC;SAAM,CAAC;QACN,OAAO,kBAAkB,CAAC;IAC5B,CAAC;AACH,CAAC;AAED,kBAAe,YAAY,CAAC","sourcesContent":["import _ from 'lodash';\nimport fs from 'fs-extra';\n\nasync function templateFile(\n templateFilePath: string,\n envs: Record<string, string | number | any>,\n outputFilePath?: string,\n { mustache = true }: { mustache?: boolean } = {}\n): Promise<string | void> {\n const templateString = await fs.readFile(templateFilePath, 'utf8');\n const compiledTemplate = _.template(\n templateString,\n mustache\n ? {\n // mustache\n interpolate: /{{([\\s\\S]+?)}}/g,\n }\n : undefined\n );\n const outputFileContents = compiledTemplate(envs);\n\n if (outputFilePath) {\n await fs.writeFile(outputFilePath, outputFileContents);\n } else {\n return outputFileContents;\n }\n}\n\nexport default templateFile;\n"]}