Skip to content

Commit 82bc115

Browse files
Merge pull request #80 from oslabs-beta/dev
Dev to Master
2 parents 1ea43dc + 041e185 commit 82bc115

File tree

5 files changed

+73
-8
lines changed

5 files changed

+73
-8
lines changed

sapling/package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"repository": "https://github.com/oslabs-beta/sapling",
66
"icon": "media/sapling-logo-128px.png",
77
"publisher": "team-sapling",
8-
"version": "1.0.0",
8+
"version": "1.1.0",
99
"engines": {
1010
"vscode": "^1.60.0"
1111
},
@@ -68,10 +68,13 @@
6868
},
6969
"scripts": {
7070
"vscode:prepublish": "npm run package",
71+
"build": "npm-run-all -p build:*",
72+
"build:extension": "webpack --mode production",
73+
"build:sidebar": "webpack --config ./src/webviews/webpack.views.config.js",
7174
"watch": "npm-run-all -p watch:*",
72-
"watch:extension": "webpack --watch --config ./src/webviews/webpack.views.config.js",
73-
"watch:sidebar": "webpack --watch",
74-
"package": "webpack --mode production --devtool hidden-source-map",
75+
"watch:extension": "webpack --watch",
76+
"watch:sidebar": "webpack --watch --config ./src/webviews/webpack.views.config.js",
77+
"package": "webpack --mode production --devtool hidden-source-map && webpack ----config ./src/webviews/webpack.views.config.js --devtool hidden-source-map",
7578
"test-compile": "tsc -p ./",
7679
"test-watch": "tsc -watch -p ./",
7780
"pretest": "npm run test-compile && npm run lint",

sapling/src/parser.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,8 @@ export class SaplingParser {
187187
// Find imports in the current file, then find child components in the current file
188188
const imports = this.getImports(ast.program.body);
189189

190-
// If current file imports React, get JSX Children:
191-
if (imports.React) {
192-
componentTree.children = this.getJSXChildren(ast.tokens, imports, componentTree);
193-
}
190+
// Get any JSX Children of current file:
191+
componentTree.children = this.getJSXChildren(ast.tokens, imports, componentTree);
194192

195193
// Check if current node is connected to the Redux store
196194
componentTree.reduxConnect = this.checkForRedux(ast.tokens, imports);

sapling/src/test/suite/parser.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,4 +282,25 @@ suite('Parser Test Suite', () => {
282282
expect(tree.children[0].children[0].children[0].children).to.have.lengthOf(0);
283283
});
284284
});
285+
286+
// TEST 12: NEXT.JS APPS
287+
describe('It should parse Next.js applications', () => {
288+
before(() => {
289+
file = path.join(__dirname, '../../../src/test/test_apps/test_12/pages/index.js');
290+
parser = new SaplingParser(file);
291+
tree = parser.parse();
292+
});
293+
294+
test('Root should be named index, children should be named Head, Navbar, and Image, children of Navbar should be named Link and Image', () => {
295+
expect(tree).to.have.own.property('name').that.is.equal('index');
296+
expect(tree.children).to.have.lengthOf(3);
297+
expect(tree.children[0]).to.have.own.property('name').that.is.equal('Head');
298+
expect(tree.children[1]).to.have.own.property('name').that.is.equal('Navbar');
299+
expect(tree.children[2]).to.have.own.property('name').that.is.equal('Image');
300+
301+
expect(tree.children[1].children).to.have.lengthOf(2);
302+
expect(tree.children[1].children[0]).to.have.own.property('name').that.is.equal('Link');
303+
expect(tree.children[1].children[1]).to.have.own.property('name').that.is.equal('Image');
304+
});
305+
});
285306
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import Image from 'next/image';
2+
import Link from 'next/link';
3+
import logo from '../public/sapling-logo.png';
4+
5+
const Navbar = () => {
6+
return (
7+
<nav id="navbar" className="navbar navbar-expand-lg navbar-light">
8+
<div className="container-fluid">
9+
<Link href="/" passHref>
10+
<Image src={logo} alt="Sapling Tree Logo"/>
11+
</Link>
12+
</div>
13+
</nav>
14+
)
15+
};
16+
17+
export default Navbar;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import Head from 'next/head'
2+
import Image from 'next/image'
3+
import Navbar from '../components/Navbar';
4+
5+
export default function Home() {
6+
return (
7+
<div className={styles.container}>
8+
<Head>
9+
<title>Sapling</title>
10+
<meta name="description" content="Generated by create next app" />
11+
<link rel="icon" href="/sapling-logo.png" />
12+
</Head>
13+
<Navbar />
14+
<main className="container">
15+
</main>
16+
<footer className="d-flex justify-content-around">
17+
<div className="d-flex flex-column align-items-center">
18+
<span>developed under</span>
19+
<a href="https://opensourcelabs.io/" target="_blank" rel="noreferrer">
20+
<Image src={osLabsLogo} alt="OSLabs Logo"/>
21+
</a>
22+
</div>
23+
</footer>
24+
</div>
25+
)
26+
}

0 commit comments

Comments
 (0)