MCPcopy Index your code
hub / github.com/adobe/react-spectrum / analyzeDeps

Function analyzeDeps

scripts/buildRegistry.mjs:124–163  ·  view source on GitHub ↗
(file, type)

Source from the content-addressed store, hash-verified

122);
123
124function 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
165function analyzeCss(file, seen = new Set()) {
166 if (seen.has(file)) {

Callers 1

buildRegistry.mjsFile · 0.85

Calls 3

sliceMethod · 0.80
addMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected