Skip to content
This repository was archived by the owner on Sep 12, 2019. It is now read-only.

Add svelte and sapper to list of detectors #201

Merged
merged 2 commits into from
Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions src/detectors/sapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const {
hasRequiredDeps,
hasRequiredFiles,
getYarnOrNPMCommand,
scanScripts
} = require("./utils/jsdetect");

module.exports = function() {
// REQUIRED FILES
if (!hasRequiredFiles(["package.json"])) return false;
// REQUIRED DEPS
if (!hasRequiredDeps(["sapper"])) return false;

/** everything below now assumes that we are within vue */

const possibleArgsArrs = scanScripts({
preferredScriptsArr: ["dev", "start"],
preferredCommand: "sapper dev"
});

if (possibleArgsArrs.length === 0) {
// ofer to run it when the user doesnt have any scripts setup! 🤯
possibleArgsArrs.push(["sapper", "dev"]);
}

return {
type: "vue-cli",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be sapper.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed

command: getYarnOrNPMCommand(),
port: 8888,
proxyPort: 3000,
env: { ...process.env },
possibleArgsArrs,
urlRegexp: new RegExp(`(http://)([^:]+:)${3000}(/)?`, "g"),
dist: "dist"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be static.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

};
};
36 changes: 36 additions & 0 deletions src/detectors/svelte.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const {
hasRequiredDeps,
hasRequiredFiles,
getYarnOrNPMCommand,
scanScripts
} = require("./utils/jsdetect");

module.exports = function() {
// REQUIRED FILES
if (!hasRequiredFiles(["package.json"])) return false;
// REQUIRED DEPS
if (!hasRequiredDeps(["svelte"])) return false;

/** everything below now assumes that we are within vue */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pedantic copy/paste leftover in comment. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh


const possibleArgsArrs = scanScripts({
preferredScriptsArr: ["dev", "start", "run"],
preferredCommand: "npm run dev"
});

if (possibleArgsArrs.length === 0) {
// ofer to run it when the user doesnt have any scripts setup! 🤯
possibleArgsArrs.push(["npm", "dev"]);
}

return {
type: "svelte",
command: getYarnOrNPMCommand(),
port: 8888,
proxyPort: 5000,
env: { ...process.env },
possibleArgsArrs,
urlRegexp: new RegExp(`(http://)([^:]+:)${5000}(/)?`, "g"),
dist: "dist"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this PR is merged already, but I was just wondering about the choice of dist here. The default Svelte template uses a public folder for its static output.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not that familiar with svelte, i didnt really check it. i have never liked the choice of dist as the keyword, as we dont care about output, we just care about the location of the _redirects file if it exists. this is a problem we'll have to fix at source

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking at this. The sapper location would be static which you updated correctly, but the Svelte default is public.

};
};