@tamagui/cli 2.7.7 → 3.0.0-beta.643.1

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
@@ -1,3 +1,4 @@
1
+
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -5,36 +6,29 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
5
6
  var __getProtoOf = Object.getPrototypeOf;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
8
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
12
13
  };
13
14
  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, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
21
22
  };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
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
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
30
26
  }) : target, mod));
31
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: true
33
- }), mod);
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
28
  var add_exports = {};
35
29
  __export(add_exports, {
36
- generatedPackageTypes: () => generatedPackageTypes,
37
- installGeneratedPackage: () => installGeneratedPackage
30
+ generatedPackageTypes: () => generatedPackageTypes,
31
+ installGeneratedPackage: () => installGeneratedPackage
38
32
  });
39
33
  module.exports = __toCommonJS(add_exports);
40
34
  var import_node_child_process = require("node:child_process");
@@ -49,70 +43,66 @@ var import_marked = require("marked");
49
43
  var import_marked_terminal = __toESM(require("marked-terminal"));
50
44
  var import_opener = __toESM(require("opener"));
51
45
  var import_prompts = __toESM(require("prompts"));
52
- import_marked.marked.setOptions({
53
- renderer: new import_marked_terminal.default()
54
- });
46
+ import_marked.marked.setOptions({ renderer: new import_marked_terminal.default() });
55
47
  const home = (0, import_node_os.homedir)();
56
48
  const tamaguiDir = import_node_path.default.join(home, ".tamagui");
57
49
  const generatedPackageTypes = ["font", "icon"];
58
50
  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
70
- });
71
- }
72
- try {
73
- process.chdir(tamaguiDir);
74
- try {
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`);
77
- } catch (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;
91
- }
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
- };
51
+ packagesPath = packagesPath || import_node_path.default.join(process.cwd(), "packages");
52
+ if (!generatedPackageTypes.includes(type)) {
53
+ throw new Error(`${type ? `Type "${type}" is Not supported.` : `No type provided.`} Supported types: ${generatedPackageTypes.join(", ")}`);
54
+ }
55
+ const repoName = type === "font" ? "tamagui-google-fonts" : "tamagui-iconify";
56
+ console.info(`Setting up ${import_chalk.default.blueBright(tamaguiDir)}...`);
57
+ await (0, import_fs_extra.ensureDir)(tamaguiDir);
58
+ const tempDir = import_node_path.default.join(tamaguiDir, repoName);
59
+ if ((0, import_node_fs.existsSync)(tempDir)) {
60
+ (0, import_node_fs.rmSync)(tempDir, { recursive: true });
61
+ }
62
+ try {
63
+ process.chdir(tamaguiDir);
64
+ try {
65
+ console.info("Attempting to clone with SSH");
66
+ (0, import_node_child_process.execSync)(`git clone -n --depth=1 --branch generated --filter=tree:0 git@github.com:tamagui/${repoName}.git`);
67
+ } catch (error) {
68
+ console.info("SSH failed - Attempting to c lone with HTTPS");
69
+ (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);
72
+ (0, import_node_child_process.execSync)([`git sparse-checkout set --no-cone meta`, `git checkout`].join(" && "));
73
+ } catch (error) {
74
+ if (error instanceof Error) {
75
+ if (error?.stderr.includes("Repository not found")) {
76
+ 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.`));
77
+ (0, import_opener.default)("https://tamagui.dev/takeout");
78
+ process.exit(0);
79
+ }
80
+ throw error;
81
+ }
82
+ }
83
+ const meta = JSON.parse(await (0, import_promises.readFile)(import_node_path.default.join(tamaguiDir, repoName, `meta`, `data.json`)).then((r) => r.toString()));
84
+ 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.`));
85
+ const result = await (0, import_prompts.default)({
86
+ name: "packageName",
87
+ type: "autocomplete",
88
+ message: type === "icon" ? `Pick an icon pack:` : type === "font" ? `Pick a font:` : `Pick one:`,
89
+ choices: Object.entries(meta).map(([slug, data]) => ({
90
+ 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})`,
91
+ value: slug
92
+ }))
93
+ });
94
+ const packageName = `${type}-${result.packageName}`;
95
+ const packageDir = import_node_path.default.join(tempDir, "packages", packageName);
96
+ process.chdir(tempDir);
97
+ (0, import_node_child_process.execSync)([`git sparse-checkout set --no-cone packages/${packageName}`, `git checkout`].join(" && "));
98
+ const finalDir = import_node_path.default.join(packagesPath, packageName);
99
+ await (0, import_fs_extra.ensureDir)(packagesPath);
100
+ await (0, import_fs_extra.copy)(packageDir, finalDir);
101
+ console.info();
102
+ console.info(import_chalk.default.green(`Created the package under ${finalDir}`));
103
+ console.info();
104
+ const readmePath = import_node_path.default.join(finalDir, "README.md");
105
+ if ((0, import_node_fs.existsSync)(readmePath)) {
106
+ console.info(import_marked.marked.parse((0, import_fs_extra.readFileSync)(readmePath).toString()));
107
+ }
108
+ };