silgi 0.36.16 → 0.36.18

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.
@@ -725,6 +725,9 @@ async function verifyDirectoryCaseSensitivity(directoryPath, rootDirectory) {
725
725
  } catch {
726
726
  }
727
727
  }
728
+ function stripCommentsAndStrings(code) {
729
+ return code.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "").replace(/"([^"\\]|\\.)*"/g, '""').replace(/'([^'\\]|\\.)*'/g, "''").replace(/`([^`\\]|\\.)*`/g, "``");
730
+ }
728
731
  async function scanSilgiExports(path, packageName, silgiInstance = useSilgiCLI()) {
729
732
  const processedFilePaths = /* @__PURE__ */ new Set();
730
733
  const alreadyScannedPaths = [];
@@ -756,14 +759,15 @@ async function scanSilgiExports(path, packageName, silgiInstance = useSilgiCLI()
756
759
  }
757
760
  try {
758
761
  const fileContent = await readFile(absoluteFilePath, "utf-8");
762
+ const cleanedContent = stripCommentsAndStrings(fileContent);
759
763
  const typeDeclarationExports = extractExportMatches(
760
764
  TYPE_DECLARATION_EXPORT_REGEX,
761
- fileContent,
765
+ cleanedContent,
762
766
  { type: "declaration" }
763
767
  );
764
768
  const functionVariableExports = extractExportMatches(
765
769
  FUNCTION_VARIABLE_EXPORT_REGEX,
766
- fileContent,
770
+ cleanedContent,
767
771
  { type: "variable" }
768
772
  );
769
773
  const allExportedEntities = [...typeDeclarationExports, ...functionVariableExports];
@@ -1118,12 +1122,19 @@ async function prepareScanFile(silgi) {
1118
1122
  ];
1119
1123
  const generateExport = (name, items, defaultEmpty = "{}") => {
1120
1124
  const hasItems = items.length > 0;
1121
- return [
1122
- `export const ${name} = ${hasItems ? "deepMergeObjects([" : defaultEmpty}`,
1123
- ...items.map((item) => ` ${item},`),
1124
- hasItems ? "])" : defaultEmpty === "{}" ? "}" : "",
1125
- ""
1126
- ];
1125
+ if (hasItems) {
1126
+ return [
1127
+ `export const ${name} = deepMergeObjects([`,
1128
+ ...items.map((item) => ` ${item},`),
1129
+ "])",
1130
+ ""
1131
+ ];
1132
+ } else {
1133
+ return [
1134
+ `export const ${name} = ${defaultEmpty}`,
1135
+ ""
1136
+ ];
1137
+ }
1127
1138
  };
1128
1139
  const importData = [
1129
1140
  "",
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
3
 
4
- const version = "0.36.16";
4
+ const version = "0.36.18";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.36.16",
4
+ "version": "0.36.18",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {