@tamagui/cli 2.0.0-rc.35 → 2.0.0-rc.36-1775243248161

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/add.cjs CHANGED
@@ -2,92 +2,117 @@ var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf,
6
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
8
+ for (var name in all) __defProp(target, name, {
9
+ get: all[name],
10
+ enumerable: true
11
+ });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
16
  get: () => from[key],
16
17
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
18
  });
18
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: true
30
+ }) : target, mod));
31
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: true
33
+ }), mod);
32
34
  var add_exports = {};
33
35
  __export(add_exports, {
34
36
  generatedPackageTypes: () => generatedPackageTypes,
35
37
  installGeneratedPackage: () => installGeneratedPackage
36
38
  });
37
39
  module.exports = __toCommonJS(add_exports);
38
- var import_node_child_process = require("node:child_process"),
39
- import_node_fs = require("node:fs"),
40
- import_promises = require("node:fs/promises"),
41
- import_node_os = require("node:os"),
42
- import_node_path = __toESM(require("node:path")),
43
- import_chalk = __toESM(require("chalk")),
44
- import_change_case = require("change-case"),
45
- import_fs_extra = require("fs-extra"),
46
- import_marked = require("marked"),
47
- import_marked_terminal = __toESM(require("marked-terminal")),
48
- import_opener = __toESM(require("opener")),
49
- import_prompts = __toESM(require("prompts"));
40
+ var import_node_child_process = require("node:child_process");
41
+ var import_node_fs = require("node:fs");
42
+ var import_promises = require("node:fs/promises");
43
+ var import_node_os = require("node:os");
44
+ var import_node_path = __toESM(require("node:path"));
45
+ var import_chalk = __toESM(require("chalk"));
46
+ var import_change_case = require("change-case");
47
+ var import_fs_extra = require("fs-extra");
48
+ var import_marked = require("marked");
49
+ var import_marked_terminal = __toESM(require("marked-terminal"));
50
+ var import_opener = __toESM(require("opener"));
51
+ var import_prompts = __toESM(require("prompts"));
50
52
  import_marked.marked.setOptions({
51
53
  renderer: new import_marked_terminal.default()
52
54
  });
53
- const home = (0, import_node_os.homedir)(),
54
- tamaguiDir = import_node_path.default.join(home, ".tamagui"),
55
- generatedPackageTypes = ["font", "icon"],
56
- installGeneratedPackage = async (type, packagesPath) => {
57
- if (packagesPath = packagesPath || import_node_path.default.join(process.cwd(), "packages"), !generatedPackageTypes.includes(type)) throw new Error(`${type ? `Type "${type}" is Not supported.` : "No type provided."} Supported types: ${generatedPackageTypes.join(", ")}`);
58
- const repoName = type === "font" ? "tamagui-google-fonts" : "tamagui-iconify";
59
- console.info(`Setting up ${import_chalk.default.blueBright(tamaguiDir)}...`), await (0, import_fs_extra.ensureDir)(tamaguiDir);
60
- const tempDir = import_node_path.default.join(tamaguiDir, repoName);
61
- (0, import_node_fs.existsSync)(tempDir) && (0, import_node_fs.rmSync)(tempDir, {
62
- recursive: !0
55
+ const home = (0, import_node_os.homedir)();
56
+ const tamaguiDir = import_node_path.default.join(home, ".tamagui");
57
+ const generatedPackageTypes = ["font", "icon"];
58
+ const installGeneratedPackage = async (type, packagesPath) => {
59
+ packagesPath = packagesPath || import_node_path.default.join(process.cwd(), "packages");
60
+ if (!generatedPackageTypes.includes(type)) {
61
+ throw new Error(`${type ? `Type "${type}" is Not supported.` : `No type provided.`} Supported types: ${generatedPackageTypes.join(", ")}`);
62
+ }
63
+ const repoName = type === "font" ? "tamagui-google-fonts" : "tamagui-iconify";
64
+ console.info(`Setting up ${import_chalk.default.blueBright(tamaguiDir)}...`);
65
+ await (0, import_fs_extra.ensureDir)(tamaguiDir);
66
+ const tempDir = import_node_path.default.join(tamaguiDir, repoName);
67
+ if ((0, import_node_fs.existsSync)(tempDir)) {
68
+ (0, import_node_fs.rmSync)(tempDir, {
69
+ recursive: true
63
70
  });
71
+ }
72
+ try {
73
+ process.chdir(tamaguiDir);
64
74
  try {
65
- process.chdir(tamaguiDir);
66
- try {
67
- console.info("Attempting to clone with SSH"), (0, import_node_child_process.execSync)(`git clone -n --depth=1 --branch generated --filter=tree:0 git@github.com:tamagui/${repoName}.git`);
68
- } catch {
69
- console.info("SSH failed - Attempting to c lone with HTTPS"), (0, import_node_child_process.execSync)(`git clone -n --depth=1 --branch generated --filter=tree:0 https://github.com/tamagui/${repoName}`);
70
- }
71
- process.chdir(tempDir), (0, import_node_child_process.execSync)(["git sparse-checkout set --no-cone meta", "git checkout"].join(" && "));
75
+ console.info("Attempting to clone with SSH");
76
+ (0, import_node_child_process.execSync)(`git clone -n --depth=1 --branch generated --filter=tree:0 git@github.com:tamagui/${repoName}.git`);
72
77
  } catch (error) {
73
- if (error instanceof Error) throw error?.stderr.includes("Repository not found") && (console.info(import_chalk.default.yellow(`You don't have access to Tamagui ${type === "font" ? "fonts" : "icons"}. Check \u{1F961} Tamagui Takeout (https://tamagui.dev/takeout) for more info.`)), (0, import_opener.default)("https://tamagui.dev/takeout"), process.exit(0)), error;
78
+ console.info("SSH failed - Attempting to c lone with HTTPS");
79
+ (0, import_node_child_process.execSync)(`git clone -n --depth=1 --branch generated --filter=tree:0 https://github.com/tamagui/${repoName}`);
80
+ }
81
+ process.chdir(tempDir);
82
+ (0, import_node_child_process.execSync)([`git sparse-checkout set --no-cone meta`, `git checkout`].join(" && "));
83
+ } catch (error) {
84
+ if (error instanceof Error) {
85
+ if (error?.stderr.includes("Repository not found")) {
86
+ console.info(import_chalk.default.yellow(`You don't have access to Tamagui ${type === "font" ? "fonts" : "icons"}. Check \u{1F961} Tamagui Takeout (https://tamagui.dev/takeout) for more info.`));
87
+ (0, import_opener.default)("https://tamagui.dev/takeout");
88
+ process.exit(0);
89
+ }
90
+ throw error;
74
91
  }
75
- const meta = JSON.parse(await (0, import_promises.readFile)(import_node_path.default.join(tamaguiDir, repoName, "meta", "data.json")).then(r => r.toString()));
76
- console.info(import_chalk.default.gray("Use \u21E7/\u21E9 to navigate. Use tab to cycle the result. Use Page Up/Page Down (on Mac: fn + \u21E7 / \u21E9) to change page. Hit enter to select the highlighted item below the prompt."));
77
- const result = await (0, import_prompts.default)({
78
- name: "packageName",
79
- type: "autocomplete",
80
- message: type === "icon" ? "Pick an icon pack:" : type === "font" ? "Pick a font:" : "Pick one:",
81
- choices: Object.entries(meta).map(([slug, data]) => ({
82
- title: type === "font" ? `${slug}: ${data.weights.length} weights, ${data.styles.length} styles, ${data.subsets.length} subsets (https://fonts.google.com/specimen/${(0, import_change_case.pascalCase)(slug)})` : `${data.name}: ${data.total} icons, ${data.license.title} license (${data.author.url})`,
83
- value: slug
84
- }))
85
- }),
86
- packageName = `${type}-${result.packageName}`,
87
- packageDir = import_node_path.default.join(tempDir, "packages", packageName);
88
- process.chdir(tempDir), (0, import_node_child_process.execSync)([`git sparse-checkout set --no-cone packages/${packageName}`, "git checkout"].join(" && "));
89
- const finalDir = import_node_path.default.join(packagesPath, packageName);
90
- await (0, import_fs_extra.ensureDir)(packagesPath), await (0, import_fs_extra.copy)(packageDir, finalDir), console.info(), console.info(import_chalk.default.green(`Created the package under ${finalDir}`)), console.info();
91
- const readmePath = import_node_path.default.join(finalDir, "README.md");
92
- (0, import_node_fs.existsSync)(readmePath) && console.info(import_marked.marked.parse((0, import_fs_extra.readFileSync)(readmePath).toString()));
93
- };
92
+ }
93
+ const meta = JSON.parse(await (0, import_promises.readFile)(import_node_path.default.join(tamaguiDir, repoName, `meta`, `data.json`)).then(r => r.toString()));
94
+ console.info(import_chalk.default.gray(`Use \u21E7/\u21E9 to navigate. Use tab to cycle the result. Use Page Up/Page Down (on Mac: fn + \u21E7 / \u21E9) to change page. Hit enter to select the highlighted item below the prompt.`));
95
+ const result = await (0, import_prompts.default)({
96
+ name: "packageName",
97
+ type: "autocomplete",
98
+ message: type === "icon" ? `Pick an icon pack:` : type === "font" ? `Pick a font:` : `Pick one:`,
99
+ choices: Object.entries(meta).map(([slug, data]) => ({
100
+ title: type === "font" ? `${slug}: ${data.weights.length} weights, ${data.styles.length} styles, ${data.subsets.length} subsets (https://fonts.google.com/specimen/${(0, import_change_case.pascalCase)(slug)})` : `${data.name}: ${data.total} icons, ${data.license.title} license (${data.author.url})`,
101
+ value: slug
102
+ }))
103
+ });
104
+ const packageName = `${type}-${result.packageName}`;
105
+ const packageDir = import_node_path.default.join(tempDir, "packages", packageName);
106
+ process.chdir(tempDir);
107
+ (0, import_node_child_process.execSync)([`git sparse-checkout set --no-cone packages/${packageName}`, `git checkout`].join(" && "));
108
+ const finalDir = import_node_path.default.join(packagesPath, packageName);
109
+ await (0, import_fs_extra.ensureDir)(packagesPath);
110
+ await (0, import_fs_extra.copy)(packageDir, finalDir);
111
+ console.info();
112
+ console.info(import_chalk.default.green(`Created the package under ${finalDir}`));
113
+ console.info();
114
+ const readmePath = import_node_path.default.join(finalDir, "README.md");
115
+ if ((0, import_node_fs.existsSync)(readmePath)) {
116
+ console.info(import_marked.marked.parse((0, import_fs_extra.readFileSync)(readmePath).toString()));
117
+ }
118
+ };