@idomatic/create 1.0.2 → 1.0.4
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/helpers/index.js +25 -0
- package/index.js +13 -4
- package/lib/initConfig.js +26 -0
- package/package.json +1 -1
package/helpers/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const defaultConfigs = {
|
|
2
|
+
react: {
|
|
3
|
+
attributeName: "id",
|
|
4
|
+
prefix: "auto-id-",
|
|
5
|
+
excludeTags: ["html", "head", "script"],
|
|
6
|
+
includeExtensions: ["js", "jsx", "ts", "tsx"],
|
|
7
|
+
excludeFiles: [],
|
|
8
|
+
},
|
|
9
|
+
vue: {
|
|
10
|
+
attributeName: "id",
|
|
11
|
+
prefix: "auto-id-",
|
|
12
|
+
excludeTags: ["html", "head", "script"],
|
|
13
|
+
includeExtensions: ["html", "vue"],
|
|
14
|
+
excludeFiles: [],
|
|
15
|
+
},
|
|
16
|
+
angular: {
|
|
17
|
+
attributeName: "id",
|
|
18
|
+
prefix: "auto-id-",
|
|
19
|
+
excludeTags: ["html", "head", "script"],
|
|
20
|
+
includeExtensions: ["html", "ng.html"],
|
|
21
|
+
excludeFiles: [],
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default defaultConfigs;
|
package/index.js
CHANGED
|
@@ -45,19 +45,28 @@ let pkg = "npm";
|
|
|
45
45
|
if (agent.includes("yarn")) pkg = "yarn";
|
|
46
46
|
else if (agent.includes("bun")) pkg = "bun";
|
|
47
47
|
|
|
48
|
-
// Install parser
|
|
48
|
+
// Install parser if opted-in
|
|
49
49
|
if (res.installParsers) {
|
|
50
50
|
const parser =
|
|
51
51
|
res.framework === "js" ? "@idomatic/parser-js" : "@idomatic/parser-html";
|
|
52
|
-
|
|
53
|
-
const installCmd = {
|
|
52
|
+
const installParserCmd = {
|
|
54
53
|
npm: `npm install ${parser}`,
|
|
55
54
|
yarn: `yarn add ${parser}`,
|
|
56
55
|
bun: `bun add ${parser}`,
|
|
57
56
|
}[pkg];
|
|
58
57
|
|
|
59
58
|
console.log(`📦 Installing ${parser} with ${pkg}...`);
|
|
60
|
-
execSync(
|
|
59
|
+
execSync(installParserCmd, { stdio: "inherit" });
|
|
61
60
|
}
|
|
62
61
|
|
|
62
|
+
// Install core package (always install it)
|
|
63
|
+
const installCoreCmd = {
|
|
64
|
+
npm: `npm install @idomatic/core`,
|
|
65
|
+
yarn: `yarn add @idomatic/core`,
|
|
66
|
+
bun: `bun add @idomatic/core`,
|
|
67
|
+
}[pkg];
|
|
68
|
+
|
|
69
|
+
console.log(`📦 Installing @idomatic/core with ${pkg}...`);
|
|
70
|
+
execSync(installCoreCmd, { stdio: "inherit" });
|
|
71
|
+
|
|
63
72
|
console.log("🎉 You're ready to run: npx idomatic --init-scan");
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import inquirer from "inquirer";
|
|
4
|
+
import defaultConfigs from "./defaultConfigs.js";
|
|
5
|
+
|
|
6
|
+
async function initConfig() {
|
|
7
|
+
const { framework } = await inquirer.prompt([
|
|
8
|
+
{
|
|
9
|
+
type: "list",
|
|
10
|
+
name: "framework",
|
|
11
|
+
message: "Select your framework:",
|
|
12
|
+
choices: ["react", "vue", "angular"],
|
|
13
|
+
default: "react",
|
|
14
|
+
},
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
const config = defaultConfigs[framework];
|
|
18
|
+
|
|
19
|
+
// Write the config to .idomaticsrc.json in the current working directory
|
|
20
|
+
const configFilePath = path.join(process.cwd(), ".idomaticsrc.json");
|
|
21
|
+
fs.writeFileSync(configFilePath, JSON.stringify(config, null, 2));
|
|
22
|
+
|
|
23
|
+
console.log(`Configuration file created at ${configFilePath}`);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
initConfig();
|