gatsby-plugin-page-creator
Advanced tools
Comparing version 1.0.1 to 1.0.2-0
"use strict"; | ||
var _parseFilepath = require("parse-filepath"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _parseFilepath2 = _interopRequireDefault(_parseFilepath); | ||
var _parseFilepath = _interopRequireDefault(require("parse-filepath")); | ||
var _path = require("path"); | ||
var _path = _interopRequireDefault(require("path")); | ||
var _path2 = _interopRequireDefault(_path); | ||
var _slash = _interopRequireDefault(require("slash")); | ||
var _slash = require("slash"); | ||
var _slash2 = _interopRequireDefault(_slash); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
module.exports = function (basePath, filePath) { | ||
var relativePath = _path2.default.posix.relative((0, _slash2.default)(basePath), (0, _slash2.default)(filePath)); | ||
var relativePath = _path.default.posix.relative((0, _slash.default)(basePath), (0, _slash.default)(filePath)); | ||
var _parsePath = (0, _parseFilepath2.default)(relativePath), | ||
var _parsePath = (0, _parseFilepath.default)(relativePath), | ||
dirname = _parsePath.dirname, | ||
name = _parsePath.name; | ||
var parsedName = name === `index` ? `` : name; | ||
return _path2.default.posix.join(`/`, dirname, parsedName, `/`); | ||
var parsedName = name === "index" ? "" : name; | ||
return _path.default.posix.join("/", dirname, parsedName, "/"); | ||
}; |
"use strict"; | ||
var _regenerator = require("babel-runtime/regenerator"); | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
var _regenerator2 = _interopRequireDefault(_regenerator); | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator"); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2); | ||
var globCB = require("glob"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var Promise = require("bluebird"); | ||
var globCB = require(`glob`); | ||
var Promise = require(`bluebird`); | ||
var _ = require(`lodash`); | ||
var chokidar = require(`chokidar`); | ||
var systemPath = require(`path`); | ||
var fs = require(`fs`); | ||
var _ = require("lodash"); | ||
var chokidar = require("chokidar"); | ||
var systemPath = require("path"); | ||
var fs = require("fs"); | ||
var glob = Promise.promisify(globCB); | ||
var createPath = require(`./create-path`); | ||
var validatePath = require(`./validate-path`); | ||
var createPath = require("./create-path"); | ||
// Path creator. | ||
var validatePath = require("./validate-path"); // Path creator. | ||
// Auto-create pages. | ||
@@ -30,63 +30,52 @@ // algorithm is glob /pages directory for js/jsx/cjsx files *not* | ||
// takes control of that page component in gatsby-node. | ||
exports.createPagesStatefully = function () { | ||
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(_ref, _ref2, doneCb) { | ||
var store = _ref.store, | ||
boundActionCreators = _ref.boundActionCreators, | ||
reporter = _ref.reporter; | ||
var pagesPath = _ref2.path, | ||
_ref2$pathCheck = _ref2.pathCheck, | ||
pathCheck = _ref2$pathCheck === undefined ? true : _ref2$pathCheck; | ||
var createPage, deletePage, program, exts, pagesDirectory, pagesGlob, files; | ||
return _regenerator2.default.wrap(function _callee$(_context) { | ||
exports.createPagesStatefully = | ||
/*#__PURE__*/ | ||
function () { | ||
var _ref3 = (0, _asyncToGenerator2.default)( | ||
/*#__PURE__*/ | ||
_regenerator.default.mark(function _callee(_ref, _ref2, doneCb) { | ||
var store, actions, reporter, pagesPath, _ref2$pathCheck, pathCheck, createPage, deletePage, program, exts, pagesDirectory, pagesGlob, files; | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
createPage = boundActionCreators.createPage, deletePage = boundActionCreators.deletePage; | ||
store = _ref.store, actions = _ref.actions, reporter = _ref.reporter; | ||
pagesPath = _ref2.path, _ref2$pathCheck = _ref2.pathCheck, pathCheck = _ref2$pathCheck === void 0 ? true : _ref2$pathCheck; | ||
createPage = actions.createPage, deletePage = actions.deletePage; | ||
program = store.getState().program; | ||
exts = program.extensions.map(function (e) { | ||
return `${e.slice(1)}`; | ||
}).join(`,`); | ||
return "" + e.slice(1); | ||
}).join(","); | ||
if (!pagesPath) { | ||
reporter.panic(` | ||
"path" is a required option for gatsby-plugin-page-creator | ||
reporter.panic("\n \"path\" is a required option for gatsby-plugin-page-creator\n\n See docs here - https://www.gatsbyjs.org/plugins/gatsby-plugin-page-creator/\n "); | ||
} // Validate that the path exists. | ||
See docs here - https://www.gatsbyjs.org/plugins/gatsby-plugin-page-creator/ | ||
`); | ||
} | ||
// Validate that the path exists. | ||
if (pathCheck && !fs.existsSync(pagesPath)) { | ||
reporter.panic(` | ||
The path passed to gatsby-plugin-page-creator does not exist on your file system: | ||
${pagesPath} | ||
Please pick a path to an existing directory. | ||
`); | ||
reporter.panic("\n The path passed to gatsby-plugin-page-creator does not exist on your file system:\n\n " + pagesPath + "\n\n Please pick a path to an existing directory.\n "); | ||
} | ||
pagesDirectory = systemPath.posix.join(pagesPath); | ||
pagesGlob = `${pagesDirectory}/**/*.{${exts}}`; | ||
pagesGlob = pagesDirectory + "/**/*.{" + exts + "}"; // Get initial list of files. | ||
// Get initial list of files. | ||
_context.next = 9; | ||
_context.next = 11; | ||
return glob(pagesGlob); | ||
case 9: | ||
case 11: | ||
files = _context.sent; | ||
files.forEach(function (file) { | ||
return _createPage(file, pagesDirectory, createPage); | ||
}); | ||
}); // Listen for new component pages to be added or removed. | ||
// Listen for new component pages to be added or removed. | ||
chokidar.watch(pagesGlob).on(`add`, function (path) { | ||
chokidar.watch(pagesGlob).on("add", function (path) { | ||
if (!_.includes(files, path)) { | ||
_createPage(path, pagesDirectory, createPage); | ||
files.push(path); | ||
} | ||
}).on(`unlink`, function (path) { | ||
}).on("unlink", function (path) { | ||
// Delete the page for the now deleted component. | ||
@@ -104,7 +93,7 @@ store.getState().pages.filter(function (p) { | ||
}); | ||
}).on(`ready`, function () { | ||
}).on("ready", function () { | ||
return doneCb(); | ||
}); | ||
case 12: | ||
case 14: | ||
case "end": | ||
@@ -114,3 +103,3 @@ return _context.stop(); | ||
} | ||
}, _callee, undefined); | ||
}, _callee, this); | ||
})); | ||
@@ -122,2 +111,3 @@ | ||
}(); | ||
var _createPage = function _createPage(filePath, pagesDirectory, createPage) { | ||
@@ -128,11 +118,11 @@ // Filter out special components that shouldn't be made into | ||
return; | ||
} | ||
} // Create page object | ||
// Create page object | ||
var page = { | ||
path: createPath(pagesDirectory, filePath), | ||
component: filePath | ||
component: filePath // Add page | ||
// Add page | ||
};createPage(page); | ||
}; | ||
createPage(page); | ||
}; |
{ | ||
"name": "gatsby-plugin-page-creator", | ||
"version": "1.0.1", | ||
"version": "1.0.2-0", | ||
"description": "Gatsby plugin that automatically creates pages from React components in specified directories", | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "babel src --out-dir . --ignore __tests__", | ||
"watch": "babel -w src --out-dir . --ignore __tests__", | ||
"build": "babel src --out-dir . --ignore **/__tests__", | ||
"watch": "babel -w src --out-dir . --ignore **/__tests__", | ||
"prepublish": "cross-env NODE_ENV=production npm run build" | ||
@@ -21,3 +21,3 @@ }, | ||
"dependencies": { | ||
"babel-runtime": "^6.26.0", | ||
"@babel/runtime": "7.0.0-beta.47", | ||
"bluebird": "^3.5.0", | ||
@@ -31,5 +31,6 @@ "chokidar": "^1.7.0", | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"@babel/cli": "7.0.0-beta.47", | ||
"@babel/core": "7.0.0-beta.47", | ||
"cross-env": "^5.0.5" | ||
} | ||
} |
"use strict"; | ||
var systemPath = require(`path`); | ||
var systemPath = require("path"); | ||
@@ -8,3 +8,3 @@ var tsDeclarationExtTest = /\.d\.tsx?$/; | ||
function isTestFile(path) { | ||
var testFileTest = new RegExp(`(/__tests__/.*|(\\.|/)(test|spec))\\.jsx?$`); | ||
var testFileTest = new RegExp("(/__tests__/.*|(\\.|/)(test|spec))\\.jsx?$"); | ||
return path.match(testFileTest); | ||
@@ -18,3 +18,3 @@ } | ||
var parsedPath = systemPath.parse(path); | ||
return parsedPath.name.slice(0, 1) !== `_` && parsedPath.name.slice(0, 9) !== `template-` && !tsDeclarationExtTest.test(parsedPath.base) && !isTestFile(parsedPath.base); | ||
return parsedPath.name.slice(0, 1) !== "_" && parsedPath.name.slice(0, 9) !== "template-" && !tsDeclarationExtTest.test(parsedPath.base) && !isTestFile(parsedPath.base); | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
7
2
7484
3
119
2
+ Added@babel/runtime@7.0.0-beta.47
+ Added@babel/runtime@7.0.0-beta.47(transitive)
- Removedbabel-runtime@^6.26.0
- Removedbabel-runtime@6.26.0(transitive)