(file, type)
| 122 | ); |
| 123 | |
| 124 | function analyzeDeps(file, type) { |
| 125 | let content = fs.readFileSync(file, 'utf8'); |
| 126 | let ast = recast.parse(content, { |
| 127 | parser: { |
| 128 | parse() { |
| 129 | return parse(content, { |
| 130 | sourceType: 'module', |
| 131 | plugins: ['typescript', 'jsx', 'importAttributes'], |
| 132 | sourceFilename: file, |
| 133 | tokens: true, |
| 134 | errorRecovery: true |
| 135 | }); |
| 136 | } |
| 137 | } |
| 138 | }); |
| 139 | |
| 140 | let dependencies = new Set(); |
| 141 | let registryDependencies = new Set(); |
| 142 | for (let node of ast.program.body) { |
| 143 | if (node.type === 'ImportDeclaration') { |
| 144 | let source = node.source.value; |
| 145 | if (source.startsWith('./')) { |
| 146 | if (!source.endsWith('.css')) { |
| 147 | registryDependencies.add( |
| 148 | publicUrl + '/' + type + '-' + source.slice(2).toLowerCase() + '.json' |
| 149 | ); |
| 150 | node.source.value = |
| 151 | source === './utils' |
| 152 | ? '@/registry/react-aria/lib/react-aria-utils' |
| 153 | : '@/registry/react-aria/ui/' + source.slice(2); |
| 154 | } |
| 155 | } else { |
| 156 | dependencies.add(source); |
| 157 | } |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | content = recast.print(ast, {objectCurlySpacing: false, quote: 'single'}).code; |
| 162 | return {dependencies, registryDependencies, content}; |
| 163 | } |
| 164 | |
| 165 | function analyzeCss(file, seen = new Set()) { |
| 166 | if (seen.has(file)) { |
no test coverage detected