untitledui 0.1.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/commands/add.js +339 -0
- package/dist/commands/init.js +436 -0
- package/dist/helper/download-tar-api.js +129 -0
- package/dist/helper/download-tar.js +81 -0
- package/dist/helper/find-css-file.js +19 -0
- package/dist/helper/formatText.js +37 -0
- package/dist/helper/get-components-api.js +47 -0
- package/dist/helper/get-components-list.js +62 -0
- package/dist/helper/get-components.js +19 -0
- package/dist/helper/get-config.js +163 -0
- package/dist/helper/get-package-info.js +99 -0
- package/dist/helper/get-pkg-manager.js +16 -0
- package/dist/helper/get-project.js +176 -0
- package/dist/helper/install-template.js +29 -0
- package/dist/helper/match-color-css.js +82 -0
- package/dist/helper/update-color-css.js +134 -0
- package/dist/index.js +25 -0
- package/dist/package.json +50 -0
- package/dist/res/components.json +520 -0
- package/dist/res/config.json +3 -0
- package/package.json +61 -0
- package/templates/default/.prettierrc +10 -0
- package/templates/default/README.md +36 -0
- package/templates/default/eslint.config.mjs +58 -0
- package/templates/default/next.config.ts +6 -0
- package/templates/default/package.json +57 -0
- package/templates/default/postcss.config.js +5 -0
- package/templates/default/public/favicon.ico +0 -0
- package/templates/default/public/marketing/smiling-girl.png +0 -0
- package/templates/default/public/marketing/spirals.webp +0 -0
- package/templates/default/src/app/home-screen.tsx +109 -0
- package/templates/default/src/app/layout.tsx +42 -0
- package/templates/default/src/app/not-found.tsx +40 -0
- package/templates/default/src/app/page.tsx +3 -0
- package/templates/default/src/components/foundations/dot-icon.tsx +27 -0
- package/templates/default/src/components/foundations/featured-icon/featured-icons.tsx +153 -0
- package/templates/default/src/components/foundations/logo/UntitledLogo.tsx +63 -0
- package/templates/default/src/components/foundations/logo/UntitledLogoMinimal.tsx +164 -0
- package/templates/default/src/components/foundations/payment-icons/amex-icon.tsx +19 -0
- package/templates/default/src/components/foundations/payment-icons/apple-pay-icon.tsx +27 -0
- package/templates/default/src/components/foundations/payment-icons/discover-icon.tsx +34 -0
- package/templates/default/src/components/foundations/payment-icons/index.tsx +10 -0
- package/templates/default/src/components/foundations/payment-icons/mastercard-icon.tsx +39 -0
- package/templates/default/src/components/foundations/payment-icons/paypal-icon.tsx +45 -0
- package/templates/default/src/components/foundations/payment-icons/stripe-icon.tsx +27 -0
- package/templates/default/src/components/foundations/payment-icons/union-pay-icon.tsx +37 -0
- package/templates/default/src/components/foundations/payment-icons/visa-icon.tsx +27 -0
- package/templates/default/src/components/marketing/header-navigation/base-components/nav-menu-item.tsx +41 -0
- package/templates/default/src/components/marketing/header-navigation/components/header.tsx +245 -0
- package/templates/default/src/components/marketing/header-navigation/dropdown-header-navigation.tsx +53 -0
- package/templates/default/src/components/shared/avatar/avatar-label-group.tsx +32 -0
- package/templates/default/src/components/shared/avatar/avatar-profile-photo.tsx +84 -0
- package/templates/default/src/components/shared/avatar/avatar.tsx +131 -0
- package/templates/default/src/components/shared/avatar/base-components/avatar-add-button.tsx +33 -0
- package/templates/default/src/components/shared/avatar/base-components/avatar-company-icon.tsx +26 -0
- package/templates/default/src/components/shared/avatar/base-components/avatar-online-indicator.tsx +31 -0
- package/templates/default/src/components/shared/avatar/base-components/index.ts +4 -0
- package/templates/default/src/components/shared/avatar/base-components/verified-tick.tsx +34 -0
- package/templates/default/src/components/shared/avatar/utils.ts +12 -0
- package/templates/default/src/components/shared/badges/badge-groups.tsx +176 -0
- package/templates/default/src/components/shared/badges/badge-types.ts +264 -0
- package/templates/default/src/components/shared/badges/badges.tsx +479 -0
- package/templates/default/src/components/shared/button-group/button-group.tsx +97 -0
- package/templates/default/src/components/shared/buttons/app-store-buttons-outline.tsx +454 -0
- package/templates/default/src/components/shared/buttons/app-store-buttons.tsx +806 -0
- package/templates/default/src/components/shared/buttons/button-utility.tsx +87 -0
- package/templates/default/src/components/shared/buttons/button.tsx +284 -0
- package/templates/default/src/components/shared/buttons/close-button.tsx +39 -0
- package/templates/default/src/components/shared/buttons/social-button.tsx +135 -0
- package/templates/default/src/components/shared/buttons/social-logos.tsx +115 -0
- package/templates/default/src/components/shared/checkbox/checkbox.tsx +120 -0
- package/templates/default/src/components/shared/dropdown/dropdown.tsx +138 -0
- package/templates/default/src/components/shared/input-dropdown/combobox.tsx +161 -0
- package/templates/default/src/components/shared/input-dropdown/dropdown-item.tsx +98 -0
- package/templates/default/src/components/shared/input-dropdown/input-dropdown.tsx +172 -0
- package/templates/default/src/components/shared/input-dropdown/multi-select.tsx +373 -0
- package/templates/default/src/components/shared/input-dropdown/popover.tsx +36 -0
- package/templates/default/src/components/shared/input-dropdown/select.tsx +63 -0
- package/templates/default/src/components/shared/inputs/file-upload-trigger.tsx +74 -0
- package/templates/default/src/components/shared/inputs/form/form.tsx +10 -0
- package/templates/default/src/components/shared/inputs/hint-text.tsx +34 -0
- package/templates/default/src/components/shared/inputs/input/index.tsx +189 -0
- package/templates/default/src/components/shared/inputs/input/input-payment.tsx +134 -0
- package/templates/default/src/components/shared/inputs/input/input-with-button.tsx +69 -0
- package/templates/default/src/components/shared/inputs/input/input-with-dropdown.tsx +178 -0
- package/templates/default/src/components/shared/inputs/input/input-with-prefix.tsx +74 -0
- package/templates/default/src/components/shared/inputs/label.tsx +46 -0
- package/templates/default/src/components/shared/inputs/textarea/textarea.tsx +82 -0
- package/templates/default/src/components/shared/progress-indicators/progress-circles.tsx +176 -0
- package/templates/default/src/components/shared/progress-indicators/progress-indicators.tsx +86 -0
- package/templates/default/src/components/shared/progress-indicators/simple-circle.tsx +29 -0
- package/templates/default/src/components/shared/radio-buttons/radio-buttons.tsx +125 -0
- package/templates/default/src/components/shared/radio-groups/radio-group-avatar.tsx +62 -0
- package/templates/default/src/components/shared/radio-groups/radio-group-checkbox.tsx +72 -0
- package/templates/default/src/components/shared/radio-groups/radio-group-icon-card.tsx +95 -0
- package/templates/default/src/components/shared/radio-groups/radio-group-icon-simple.tsx +70 -0
- package/templates/default/src/components/shared/radio-groups/radio-group-payment-icon.tsx +71 -0
- package/templates/default/src/components/shared/radio-groups/radio-group-radio-button.tsx +76 -0
- package/templates/default/src/components/shared/radio-groups/radio-groups.tsx +8 -0
- package/templates/default/src/components/shared/slider/slider.tsx +76 -0
- package/templates/default/src/components/shared/tags/base-components/tag-checkbox.tsx +47 -0
- package/templates/default/src/components/shared/tags/base-components/tag-close-x.tsx +34 -0
- package/templates/default/src/components/shared/tags/tags.tsx +162 -0
- package/templates/default/src/components/shared/toggle/toggle.tsx +140 -0
- package/templates/default/src/components/shared/tooltips/tooltips.tsx +140 -0
- package/templates/default/src/components/utils/index.ts +48 -0
- package/templates/default/src/components/utils/isDeepEqual.ts +31 -0
- package/templates/default/src/components/utils/isReactComponent.ts +22 -0
- package/templates/default/src/components/utils/mergeRefs.ts +19 -0
- package/templates/default/src/components/utils/useBreakpoint.ts +36 -0
- package/templates/default/src/components/utils/uuid.ts +9 -0
- package/templates/default/src/fonts/GeistMonoVF.woff +0 -0
- package/templates/default/src/fonts/GeistVF.woff +0 -0
- package/templates/default/src/hooks/use-resize-observer.tsx +55 -0
- package/templates/default/src/providers/theme.tsx +11 -0
- package/templates/default/src/styles/colors.css +805 -0
- package/templates/default/src/styles/globals.css +86 -0
- package/templates/default/src/styles/text-styles.css +177 -0
- package/templates/default/src/styles/theme.css +1310 -0
- package/templates/default/src/styles/typography.css +428 -0
- package/templates/default/tsconfig.json +27 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.formatWithPrettier = formatWithPrettier;
|
|
16
|
+
const prettier_1 = __importDefault(require("prettier"));
|
|
17
|
+
/**
|
|
18
|
+
* Formats text using Prettier.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} text - The text to format.
|
|
21
|
+
* @param {string} parser - The parser to use, e.g., "typescript" or "babel".
|
|
22
|
+
* @returns {string} - The formatted text.
|
|
23
|
+
*/
|
|
24
|
+
function formatWithPrettier(text_1) {
|
|
25
|
+
return __awaiter(this, arguments, void 0, function* (text, parser = "typescript") {
|
|
26
|
+
try {
|
|
27
|
+
const formattedText = yield prettier_1.default.format(text, {
|
|
28
|
+
parser,
|
|
29
|
+
});
|
|
30
|
+
return formattedText;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
console.error("Error formatting with Prettier:", error);
|
|
34
|
+
return text;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.getComponents = getComponents;
|
|
16
|
+
const config_json_1 = __importDefault(require("../res/config.json"));
|
|
17
|
+
/**
|
|
18
|
+
* Fetches the JSON data for the components
|
|
19
|
+
* @param type - Type of component
|
|
20
|
+
* @param components - List of components
|
|
21
|
+
* @param key - License key
|
|
22
|
+
* @returns JSON data for the components or null if no data is found
|
|
23
|
+
*/
|
|
24
|
+
function getComponents(type, components, key) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
var _a;
|
|
27
|
+
const apiUrl = `${config_json_1.default.api_url}/components`;
|
|
28
|
+
try {
|
|
29
|
+
const res = yield fetch(apiUrl, {
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers: {
|
|
32
|
+
"Content-Type": "application/json",
|
|
33
|
+
Accept: "application/json",
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify({ type, components, key }),
|
|
36
|
+
});
|
|
37
|
+
const data = yield res.json();
|
|
38
|
+
if (!((_a = data === null || data === void 0 ? void 0 : data.components) === null || _a === void 0 ? void 0 : _a.length))
|
|
39
|
+
return null;
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
console.error(err);
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.getComponentsList = getComponentsList;
|
|
16
|
+
exports.getComponentTypes = getComponentTypes;
|
|
17
|
+
const config_json_1 = __importDefault(require("../res/config.json"));
|
|
18
|
+
/**
|
|
19
|
+
* Fetches the JSON data for the components
|
|
20
|
+
* @param key - License key
|
|
21
|
+
* @param componentType - Type of the component (i.e. shared, marketing)
|
|
22
|
+
* @returns JSON data for the components or null if no data is found
|
|
23
|
+
*/
|
|
24
|
+
function getComponentsList(componentType_1) {
|
|
25
|
+
return __awaiter(this, arguments, void 0, function* (componentType, key = "") {
|
|
26
|
+
var _a;
|
|
27
|
+
const apiUrl = `${config_json_1.default.api_url}/components/list?key=${key}&type=${componentType}`;
|
|
28
|
+
try {
|
|
29
|
+
const res = yield fetch(apiUrl);
|
|
30
|
+
const data = yield res.json();
|
|
31
|
+
if (!((_a = data === null || data === void 0 ? void 0 : data.components) === null || _a === void 0 ? void 0 : _a.length))
|
|
32
|
+
return null;
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
console.error(err);
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Fetches the list of component types
|
|
43
|
+
* @param key - License key
|
|
44
|
+
* @returns JSON data for the list of component types or null if no data is found
|
|
45
|
+
*/
|
|
46
|
+
function getComponentTypes() {
|
|
47
|
+
return __awaiter(this, arguments, void 0, function* (key = "") {
|
|
48
|
+
var _a;
|
|
49
|
+
const apiUrl = `${config_json_1.default.api_url}/components/list?key=${key}`;
|
|
50
|
+
try {
|
|
51
|
+
const res = yield fetch(apiUrl);
|
|
52
|
+
const data = yield res.json();
|
|
53
|
+
if (!((_a = data === null || data === void 0 ? void 0 : data.types) === null || _a === void 0 ? void 0 : _a.length))
|
|
54
|
+
return null;
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
console.error(err);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
exports.getComponentPaths = getComponentPaths;
|
|
7
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves the absolute paths of components based on specified file patterns and options.
|
|
10
|
+
*
|
|
11
|
+
* @param cwd - The current working directory in which fast-glob will search.
|
|
12
|
+
* @param componentPaths - An array of file patterns (globs) to match for components.
|
|
13
|
+
* @param options - Additional fast-glob options to control the matching behavior.
|
|
14
|
+
* @returns An array of matched file paths, returned in absolute format.
|
|
15
|
+
*/
|
|
16
|
+
function getComponentPaths(cwd, componentPaths, options) {
|
|
17
|
+
const componentsPaths = fast_glob_1.default.sync(componentPaths, Object.assign(Object.assign({ absolute: true }, options), { cwd }));
|
|
18
|
+
return componentsPaths;
|
|
19
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.resolveConfigPaths = resolveConfigPaths;
|
|
49
|
+
exports.updateImportAliases = updateImportAliases;
|
|
50
|
+
exports.updateTsConfig = updateTsConfig;
|
|
51
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
52
|
+
const fs = __importStar(require("fs"));
|
|
53
|
+
const path = __importStar(require("path"));
|
|
54
|
+
const ts_morph_1 = require("ts-morph");
|
|
55
|
+
const tsconfig_paths_1 = require("tsconfig-paths");
|
|
56
|
+
const formatText_1 = require("./formatText");
|
|
57
|
+
const get_project_1 = require("./get-project");
|
|
58
|
+
/**
|
|
59
|
+
* Resolves various project configuration file paths based on the given working directory.
|
|
60
|
+
*
|
|
61
|
+
* @param cwd - The current working directory where the project resides.
|
|
62
|
+
* @returns An object containing paths to the project's configuration files.
|
|
63
|
+
* @throws Error if the tsconfig.json file cannot be loaded.
|
|
64
|
+
*/
|
|
65
|
+
function resolveConfigPaths(cwd) {
|
|
66
|
+
var _a;
|
|
67
|
+
// Read tsconfig.json.
|
|
68
|
+
const tsConfig = (0, tsconfig_paths_1.loadConfig)(cwd);
|
|
69
|
+
// Search for configuration files such as
|
|
70
|
+
// tailwind.config.js, globals.css, layout.tsx, _app.tsx, and package.json.
|
|
71
|
+
const files = fast_glob_1.default.sync(["tailwind.config.*", "**/globals.css", "**/{layout,_app}.tsx", "package.json"], {
|
|
72
|
+
cwd,
|
|
73
|
+
deep: 4,
|
|
74
|
+
absolute: true,
|
|
75
|
+
onlyFiles: true,
|
|
76
|
+
ignore: get_project_1.PROJECT_SHARED_IGNORE,
|
|
77
|
+
});
|
|
78
|
+
// Return the paths to the configuration files.
|
|
79
|
+
const config = {
|
|
80
|
+
tailwindFile: files.find((file) => file.includes("tailwind.config.")),
|
|
81
|
+
cssFile: files.find((file) => file.includes("globals.css")),
|
|
82
|
+
layoutFile: files.find((file) => file.includes("layout")),
|
|
83
|
+
appFile: files.find((file) => file.includes("_app")),
|
|
84
|
+
packageJson: files.find((file) => file.includes("package.json")),
|
|
85
|
+
tsConfig: (tsConfig === null || tsConfig === void 0 ? void 0 : tsConfig.resultType) === "success" ? tsConfig === null || tsConfig === void 0 ? void 0 : tsConfig.configFileAbsolutePath : undefined,
|
|
86
|
+
};
|
|
87
|
+
if (tsConfig.resultType === "failed") {
|
|
88
|
+
throw new Error(`Failed to load tsconfig.json. ${(_a = tsConfig.message) !== null && _a !== void 0 ? _a : ""}`.trim());
|
|
89
|
+
}
|
|
90
|
+
return config;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Updates module specifier aliases based on project alias configuration.
|
|
94
|
+
*
|
|
95
|
+
* @param moduleSpecifier - The module specifier string to be updated.
|
|
96
|
+
* @param alias - Object containing alias prefix mappings.
|
|
97
|
+
* @param componentPath - Optional path to a component being referenced. It will be provided by user during component addition. By default, it is components/.
|
|
98
|
+
* @returns The updated module specifier with the correct alias replacement.
|
|
99
|
+
*/
|
|
100
|
+
function updateImportAliases(moduleSpecifier, alias, componentPath) {
|
|
101
|
+
if (moduleSpecifier.includes("components")) {
|
|
102
|
+
// Before updating the module specifier, make sure to check if
|
|
103
|
+
// componentPath matches with componentsPrefix as
|
|
104
|
+
// it might conflict with the default components/ path.
|
|
105
|
+
if (alias === null || alias === void 0 ? void 0 : alias.componentsPrefix) {
|
|
106
|
+
return moduleSpecifier.replace(/@\/components\//, path.join(alias === null || alias === void 0 ? void 0 : alias.componentsPrefix, componentPath ? componentPath.replace(/components\//, "") : "", "/"));
|
|
107
|
+
}
|
|
108
|
+
if (componentPath) {
|
|
109
|
+
return moduleSpecifier.replace(/@\/components\//, path.join((alias === null || alias === void 0 ? void 0 : alias.srcPrefix) || "@/", componentPath, "/"));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (moduleSpecifier.includes("app") && (alias === null || alias === void 0 ? void 0 : alias.appPrefix)) {
|
|
113
|
+
return moduleSpecifier.replace(/^@\/app\//, alias === null || alias === void 0 ? void 0 : alias.appPrefix);
|
|
114
|
+
}
|
|
115
|
+
if (moduleSpecifier.includes("utils") && (alias === null || alias === void 0 ? void 0 : alias.utilsPrefix)) {
|
|
116
|
+
return moduleSpecifier.replace(/^@\/utils\//, alias === null || alias === void 0 ? void 0 : alias.utilsPrefix);
|
|
117
|
+
}
|
|
118
|
+
if (moduleSpecifier.includes("styles") && (alias === null || alias === void 0 ? void 0 : alias.stylesPrefix)) {
|
|
119
|
+
return moduleSpecifier.replace(/^@\/styles\//, alias === null || alias === void 0 ? void 0 : alias.stylesPrefix);
|
|
120
|
+
}
|
|
121
|
+
if (alias === null || alias === void 0 ? void 0 : alias.srcPrefix) {
|
|
122
|
+
return moduleSpecifier.replace(/^@\//, alias === null || alias === void 0 ? void 0 : alias.srcPrefix);
|
|
123
|
+
}
|
|
124
|
+
return moduleSpecifier;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Updates the TypeScript configuration file (`tsconfig.json`) with proper alias paths if it's not provided in file and returns the alias prefix.
|
|
128
|
+
*
|
|
129
|
+
* @param cwd - The current working directory where `tsconfig.json` is located.
|
|
130
|
+
* @param isSrcDir - Boolean flag indicating if the project uses a `src/` directory structure.
|
|
131
|
+
* @param aliasPath - The alias path format, defaulting to `@/*`.
|
|
132
|
+
* @returns A promise resolving to an object containing alias prefixes or `null` if it fails to find (`tsconfig.json`).
|
|
133
|
+
*/
|
|
134
|
+
function updateTsConfig(cwd_1, isSrcDir_1) {
|
|
135
|
+
return __awaiter(this, arguments, void 0, function* (cwd, isSrcDir, aliasPath = "@/*") {
|
|
136
|
+
const tsConfig = yield (0, tsconfig_paths_1.loadConfig)(cwd);
|
|
137
|
+
if ((tsConfig === null || tsConfig === void 0 ? void 0 : tsConfig.resultType) === "failed")
|
|
138
|
+
return null;
|
|
139
|
+
const aliasPrefix = {};
|
|
140
|
+
// If paths are not provided in tsconfig.json, adds them.
|
|
141
|
+
if (!Object.keys(tsConfig.paths).length) {
|
|
142
|
+
tsConfig.paths = {
|
|
143
|
+
[aliasPath]: [`./${isSrcDir ? "src/" : ""}*`],
|
|
144
|
+
};
|
|
145
|
+
aliasPrefix.srcPrefix = aliasPath.replace(/\/\*$/, "");
|
|
146
|
+
const tsConfigFile = yield fs.promises.readFile(tsConfig.configFileAbsolutePath, "utf-8");
|
|
147
|
+
let updatedTsConfig;
|
|
148
|
+
if (!tsConfigFile.includes('"paths":')) {
|
|
149
|
+
updatedTsConfig = tsConfigFile.replace(/"compilerOptions":\s*{/, `"compilerOptions": {
|
|
150
|
+
"paths": ${JSON.stringify(tsConfig.paths)},`);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
updatedTsConfig = tsConfigFile.replace(/"paths":\s*{[^}]*}/, `"paths": ${JSON.stringify(tsConfig.paths)}`);
|
|
154
|
+
}
|
|
155
|
+
const project = new ts_morph_1.Project();
|
|
156
|
+
const formattedTsConfig = yield (0, formatText_1.formatWithPrettier)(updatedTsConfig, "json");
|
|
157
|
+
project.createSourceFile(tsConfig.configFileAbsolutePath, formattedTsConfig, { overwrite: true });
|
|
158
|
+
yield project.save();
|
|
159
|
+
return aliasPrefix;
|
|
160
|
+
}
|
|
161
|
+
return aliasPrefix || null;
|
|
162
|
+
});
|
|
163
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getPackageInfo = getPackageInfo;
|
|
40
|
+
exports.getDependenciesFromPackageJson = getDependenciesFromPackageJson;
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const path_1 = __importDefault(require("path"));
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @param cwd - The current working directory where `package.json` is located.
|
|
46
|
+
* @param shouldThrow - Boolean flag indicating if it should throw an error if `package.json` is not found.
|
|
47
|
+
* @returns A promise resolving to the parsed `package.json` file or `null` if it fails to find (`package.json`).
|
|
48
|
+
*/
|
|
49
|
+
function getPackageInfo(cwd = "", shouldThrow = true) {
|
|
50
|
+
const packageJsonPath = path_1.default.join(cwd, "package.json");
|
|
51
|
+
if (!fs.existsSync(packageJsonPath)) {
|
|
52
|
+
if (shouldThrow) {
|
|
53
|
+
throw new Error("package.json not found");
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const packageJson = fs.readFileSync(packageJsonPath, "utf8");
|
|
58
|
+
return JSON.parse(packageJson);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Retrieves dependencies and devDependencies from the package.json file along with their versions.
|
|
62
|
+
*
|
|
63
|
+
* @param cwd - The current working directory where package.json is located.
|
|
64
|
+
* @param shouldThrow - Boolean flag indicating whether to throw an error if package.json is not found.
|
|
65
|
+
* @param dependencies - Optional list of specific dependencies to retrieve.
|
|
66
|
+
* @param devDependencies - Optional list of specific devDependencies to retrieve.
|
|
67
|
+
* @returns An object containing dependencies and devDependencies with their versions (formatted as `package@version`).
|
|
68
|
+
*/
|
|
69
|
+
function getDependenciesFromPackageJson({ cwd = "", dependencies, devDependencies, shouldThrow = true, }) {
|
|
70
|
+
const packageJson = getPackageInfo(cwd, shouldThrow);
|
|
71
|
+
if (!packageJson) {
|
|
72
|
+
if (shouldThrow)
|
|
73
|
+
throw new Error("package.json not found");
|
|
74
|
+
else
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
const dep = [];
|
|
78
|
+
const devDep = [];
|
|
79
|
+
if (dependencies) {
|
|
80
|
+
dependencies.forEach((dependency) => {
|
|
81
|
+
var _a;
|
|
82
|
+
if ((_a = packageJson.dependencies) === null || _a === void 0 ? void 0 : _a[dependency]) {
|
|
83
|
+
dep.push(`${dependency}@${packageJson.dependencies[dependency]}`);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if (devDependencies) {
|
|
88
|
+
devDependencies.forEach((dependency) => {
|
|
89
|
+
var _a;
|
|
90
|
+
if ((_a = packageJson.devDependencies) === null || _a === void 0 ? void 0 : _a[dependency]) {
|
|
91
|
+
devDep.push(`${dependency}@${packageJson.devDependencies[dependency]}`);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
dependencies: dep,
|
|
97
|
+
devDependencies: devDep,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPkgManager = getPkgManager;
|
|
4
|
+
function getPkgManager() {
|
|
5
|
+
const userAgent = process.env.npm_config_user_agent || "";
|
|
6
|
+
if (userAgent.startsWith("yarn")) {
|
|
7
|
+
return "yarn";
|
|
8
|
+
}
|
|
9
|
+
if (userAgent.startsWith("pnpm")) {
|
|
10
|
+
return "pnpm";
|
|
11
|
+
}
|
|
12
|
+
if (userAgent.startsWith("bun")) {
|
|
13
|
+
return "bun";
|
|
14
|
+
}
|
|
15
|
+
return "npm";
|
|
16
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.FRAMEWORKS = exports.PROJECT_SHARED_IGNORE = void 0;
|
|
49
|
+
exports.getNextjsProjectConfig = getNextjsProjectConfig;
|
|
50
|
+
exports.isTypeScriptProject = isTypeScriptProject;
|
|
51
|
+
exports.getTailwindConfigFile = getTailwindConfigFile;
|
|
52
|
+
exports.getTsConfigAliasPrefix = getTsConfigAliasPrefix;
|
|
53
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
54
|
+
const fs = __importStar(require("fs"));
|
|
55
|
+
const path = __importStar(require("path"));
|
|
56
|
+
const tsconfig_paths_1 = require("tsconfig-paths");
|
|
57
|
+
exports.PROJECT_SHARED_IGNORE = ["**/node_modules/**", ".next", "public", "dist", "build"];
|
|
58
|
+
exports.FRAMEWORKS = {
|
|
59
|
+
"next-app": "Next.js (App)",
|
|
60
|
+
"next-pages": "Next.js (Pages)",
|
|
61
|
+
other: "Other",
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Retrieves the framework configuration and project settings for a Next.js-based project.
|
|
65
|
+
*
|
|
66
|
+
* @param cwd - The current working directory where the project resides.
|
|
67
|
+
* @returns An object containing the project framework, TypeScript usage, alias prefix, Tailwind configuration, and directory structure.
|
|
68
|
+
*/
|
|
69
|
+
function getNextjsProjectConfig(cwd) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
var _a;
|
|
72
|
+
// Check if the project is using the src directory.
|
|
73
|
+
const isSrcDir = fs.existsSync(path.resolve(cwd, "src"));
|
|
74
|
+
// Check if the project is using the app directory.
|
|
75
|
+
const isUsingAppDir = fs.existsSync(path.resolve(cwd, `${isSrcDir ? "src/" : ""}app`));
|
|
76
|
+
const [files, isTsx, tailwindFile, aliasPrefix] = yield Promise.all([
|
|
77
|
+
fast_glob_1.default.glob("**/{next,vite,astro}.config.*|gatsby-config.*", {
|
|
78
|
+
cwd,
|
|
79
|
+
deep: 2,
|
|
80
|
+
ignore: exports.PROJECT_SHARED_IGNORE,
|
|
81
|
+
}),
|
|
82
|
+
isTypeScriptProject(cwd),
|
|
83
|
+
getTailwindConfigFile(cwd),
|
|
84
|
+
getTsConfigAliasPrefix(cwd),
|
|
85
|
+
]);
|
|
86
|
+
const info = {
|
|
87
|
+
framework: "other",
|
|
88
|
+
isTsx,
|
|
89
|
+
tailwindFile,
|
|
90
|
+
aliasPrefix,
|
|
91
|
+
isSrcDir,
|
|
92
|
+
isUsingAppDir,
|
|
93
|
+
};
|
|
94
|
+
// Check if the project is using Next.js by looking for next.config files.
|
|
95
|
+
if ((_a = files.find((file) => file.startsWith("next.config."))) === null || _a === void 0 ? void 0 : _a.length) {
|
|
96
|
+
info["framework"] = isUsingAppDir ? "next-app" : "next-pages";
|
|
97
|
+
return info;
|
|
98
|
+
// Else check if it's existing project and uses other frameworks.
|
|
99
|
+
}
|
|
100
|
+
else if ((files === null || files === void 0 ? void 0 : files.length) || fs.existsSync(path.resolve(cwd, "package.json"))) {
|
|
101
|
+
info["framework"] = "other";
|
|
102
|
+
return info;
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Determines if the project is using TypeScript by checking for tsconfig files.
|
|
109
|
+
*
|
|
110
|
+
* @param cwd - The current working directory where the project resides.
|
|
111
|
+
* @returns A boolean indicating if the project uses TypeScript.
|
|
112
|
+
*/
|
|
113
|
+
function isTypeScriptProject(cwd) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
const files = yield fast_glob_1.default.glob("tsconfig.*", {
|
|
116
|
+
cwd,
|
|
117
|
+
deep: 2,
|
|
118
|
+
ignore: exports.PROJECT_SHARED_IGNORE,
|
|
119
|
+
});
|
|
120
|
+
return files.length > 0;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Finds the Tailwind CSS configuration file in the project directory.
|
|
125
|
+
*
|
|
126
|
+
* @param cwd - The current working directory where the project resides.
|
|
127
|
+
* @returns The path to the Tailwind CSS configuration file or null if not found.
|
|
128
|
+
*/
|
|
129
|
+
function getTailwindConfigFile(cwd) {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
const files = yield fast_glob_1.default.glob("tailwind.config.*", {
|
|
132
|
+
cwd,
|
|
133
|
+
deep: 2,
|
|
134
|
+
ignore: exports.PROJECT_SHARED_IGNORE,
|
|
135
|
+
});
|
|
136
|
+
if (!files.length) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
return files[0];
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Extracts alias prefixes from the TypeScript configuration (tsconfig.json).
|
|
144
|
+
*
|
|
145
|
+
* @param cwd - The current working directory where the project resides.
|
|
146
|
+
* @returns An object containing alias prefixes or null if not found.
|
|
147
|
+
*/
|
|
148
|
+
function getTsConfigAliasPrefix(cwd) {
|
|
149
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
const tsConfig = yield (0, tsconfig_paths_1.loadConfig)(cwd);
|
|
151
|
+
if ((tsConfig === null || tsConfig === void 0 ? void 0 : tsConfig.resultType) === "failed" || !Object.keys(tsConfig.paths).length) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
const aliasPrefix = {};
|
|
155
|
+
// This assume that the first alias is the prefix.
|
|
156
|
+
for (const [alias, paths] of Object.entries(tsConfig.paths)) {
|
|
157
|
+
const cleanedAlias = alias.replace(/\/\*$/, "/");
|
|
158
|
+
if (paths.some((path) => path.includes("/app/*"))) {
|
|
159
|
+
aliasPrefix.appPrefix = cleanedAlias;
|
|
160
|
+
}
|
|
161
|
+
else if (paths.some((path) => path.includes("/components/*"))) {
|
|
162
|
+
aliasPrefix.componentsPrefix = cleanedAlias;
|
|
163
|
+
}
|
|
164
|
+
else if (paths.some((path) => path.includes("/utils/*"))) {
|
|
165
|
+
aliasPrefix.utilsPrefix = cleanedAlias;
|
|
166
|
+
}
|
|
167
|
+
else if (paths.some((path) => path.includes("/styles/*"))) {
|
|
168
|
+
aliasPrefix.stylesPrefix = cleanedAlias;
|
|
169
|
+
}
|
|
170
|
+
else if (paths.some((path) => path.includes("./*") || path.includes("/src/*"))) {
|
|
171
|
+
aliasPrefix.srcPrefix = cleanedAlias;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return aliasPrefix || null;
|
|
175
|
+
});
|
|
176
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
exports.copyTemplateFiles = copyTemplateFiles;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
/**
|
|
10
|
+
* Recursively copies all files and folders from a source directory to a destination directory.
|
|
11
|
+
* @param {string} src - Source directory path.
|
|
12
|
+
* @param {string} dest - Destination directory path.
|
|
13
|
+
*/
|
|
14
|
+
function copyTemplateFiles(src, dest) {
|
|
15
|
+
if (!fs_1.default.existsSync(dest)) {
|
|
16
|
+
fs_1.default.mkdirSync(dest, { recursive: true });
|
|
17
|
+
}
|
|
18
|
+
const entries = fs_1.default.readdirSync(src, { withFileTypes: true });
|
|
19
|
+
for (const entry of entries) {
|
|
20
|
+
const srcPath = path_1.default.join(src, entry.name);
|
|
21
|
+
const destPath = path_1.default.join(dest, entry.name);
|
|
22
|
+
if (entry.isDirectory()) {
|
|
23
|
+
copyTemplateFiles(srcPath, destPath);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
fs_1.default.copyFileSync(srcPath, destPath);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|