WIP - add extractor, generate snippet_data
This commit is contained in:
28
node_modules/gatsby-page-utils/CHANGELOG.md
generated
vendored
Normal file
28
node_modules/gatsby-page-utils/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
# Change Log
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [0.0.5](https://github.com/gatsbyjs/gatsby/compare/gatsby-page-utils@0.0.4...gatsby-page-utils@0.0.5) (2019-07-13)
|
||||
|
||||
**Note:** Version bump only for package gatsby-page-utils
|
||||
|
||||
## [0.0.4](https://github.com/gatsbyjs/gatsby/compare/gatsby-page-utils@0.0.3...gatsby-page-utils@0.0.4) (2019-07-12)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- correct links in package changelogs ([#15630](https://github.com/gatsbyjs/gatsby/issues/15630)) ([d07b9dd](https://github.com/gatsbyjs/gatsby/commit/d07b9dd))
|
||||
|
||||
## [0.0.3](https://github.com/gatsbyjs/gatsby/compare/gatsby-page-utils@0.0.2...gatsby-page-utils@0.0.3) (2019-07-11)
|
||||
|
||||
**Note:** Version bump only for package gatsby-page-utils
|
||||
|
||||
## 0.0.2 (2019-06-24)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
- **gatsby-page-utils:** check-version-mismatch ([d0fabd3](https://github.com/gatsbyjs/gatsby/commit/d0fabd3))
|
||||
|
||||
### Features
|
||||
|
||||
- **gatsby-page-utils:** extract logic for watching a directory from gatsby-page-creator so can reuse for custom page creation ([#14051](https://github.com/gatsbyjs/gatsby/issues/14051)) ([68d9d6f](https://github.com/gatsbyjs/gatsby/commit/68d9d6f))
|
||||
22
node_modules/gatsby-page-utils/LICENSE
generated
vendored
Normal file
22
node_modules/gatsby-page-utils/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Gatsbyjs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
96
node_modules/gatsby-page-utils/README.md
generated
vendored
Normal file
96
node_modules/gatsby-page-utils/README.md
generated
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
# gatsby-page-utils
|
||||
|
||||
## Usage
|
||||
|
||||
```sh
|
||||
npm install gatsby-page-utils
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```js
|
||||
const {
|
||||
createPath,
|
||||
ignorePath,
|
||||
validatePath,
|
||||
watchDirectory,
|
||||
} = require(`gatsby-page-utils`)
|
||||
|
||||
// ...
|
||||
|
||||
const pagesDirectory = "/pages"
|
||||
watchDirectory(
|
||||
pagesDirectory,
|
||||
"**/*.{js, jsx}",
|
||||
addedPath => {
|
||||
// Filter out special components that shouldn't be made into
|
||||
// pages.
|
||||
if (!validatePath(addedPath)) {
|
||||
return
|
||||
}
|
||||
|
||||
// Filter out anything matching the given ignore patterns and options
|
||||
if (ignorePath(addedPath, "*/connexion")) {
|
||||
return
|
||||
}
|
||||
|
||||
// Create page object
|
||||
const createdPath = createPath(addedPath)
|
||||
const page = {
|
||||
path: createdPath,
|
||||
component: systemPath.join(pagesDirectory, addedPath),
|
||||
}
|
||||
|
||||
// Add page
|
||||
createPage(page)
|
||||
},
|
||||
removedPath => {
|
||||
// Delete the page for the now deleted component.
|
||||
const componentPath = systemPath.join(pagesDirectory, removedPath)
|
||||
store.getState().pages.forEach(page => {
|
||||
if (page.component === componentPath) {
|
||||
deletePage({
|
||||
path: createPath(removedPath),
|
||||
component: componentPath,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
#### watchDirectory
|
||||
|
||||
Watch activity on a directory and call functions each time a file is added or removed
|
||||
|
||||
| property | description | type |
|
||||
| ------------- | ----------------------------------------------- | -------- |
|
||||
| path | Directory path in which pages are stored | String |
|
||||
| glob | A glob that select files to watch | String |
|
||||
| onNewFile | A function called each time a new file is added | Function |
|
||||
| onRemovedFile | A function called each time a file is removed | Function |
|
||||
|
||||
#### createPath
|
||||
|
||||
Create a page path from a file path. It returns the page path.
|
||||
|
||||
| property | description | type |
|
||||
| -------- | ----------- | ------ |
|
||||
| path | File path | String |
|
||||
|
||||
#### validatePath
|
||||
|
||||
Validate a file path. It veryfies that it doesn't contains specific characters or strings. It returns `true` if path is valid otherwise it returns `false`.
|
||||
|
||||
| property | description | type |
|
||||
| -------- | ----------- | ------ |
|
||||
| path | File path | String |
|
||||
|
||||
#### ignorePath
|
||||
|
||||
Determines if path should be ignored regarding of a ignore pattern passed as parameter. It returns `true` if the passed path should be ignored otherwise it returns `false`.
|
||||
|
||||
| property | description | type |
|
||||
| -------- | --------------------------------- | ------- |
|
||||
| path | File path | String |
|
||||
| ignore | A pattern to match with file path | (Object | String | Array) |
|
||||
12
node_modules/gatsby-page-utils/dist/create-path.js
generated
vendored
Normal file
12
node_modules/gatsby-page-utils/dist/create-path.js
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
var path = require("path");
|
||||
|
||||
module.exports = function (filePath) {
|
||||
var _path$parse = path.parse(filePath),
|
||||
dir = _path$parse.dir,
|
||||
name = _path$parse.name;
|
||||
|
||||
var parsedName = name === "index" ? "" : name;
|
||||
return path.posix.join("/", dir, parsedName, "/");
|
||||
};
|
||||
26
node_modules/gatsby-page-utils/dist/ignore-path.js
generated
vendored
Normal file
26
node_modules/gatsby-page-utils/dist/ignore-path.js
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
|
||||
var mm = require("micromatch");
|
||||
|
||||
module.exports = function (path, ignore) {
|
||||
// Don't do anything if no ignore patterns
|
||||
if (!ignore) return false;
|
||||
var settings = {
|
||||
patterns: ignore.patterns,
|
||||
options: ignore.options // Allow shorthand ignore patterns ['pattern'] or 'pattern'
|
||||
|
||||
};
|
||||
|
||||
if (!ignore.patterns) {
|
||||
if (Array.isArray(ignore) && ignore.length > 0) {
|
||||
settings.patterns = ignore;
|
||||
} else if (typeof ignore != "object") {
|
||||
settings.patterns = ignore.toString();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} // Return true if the path should be ignored (matches any given ignore patterns)
|
||||
|
||||
|
||||
return mm.any(path, settings.patterns, settings.options);
|
||||
};
|
||||
8
node_modules/gatsby-page-utils/dist/index.js
generated
vendored
Normal file
8
node_modules/gatsby-page-utils/dist/index.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
validatePath: require("./validate-path"),
|
||||
createPath: require("./create-path"),
|
||||
ignorePath: require("./ignore-path"),
|
||||
watchDirectory: require("./watch-directory")
|
||||
};
|
||||
21
node_modules/gatsby-page-utils/dist/validate-path.js
generated
vendored
Normal file
21
node_modules/gatsby-page-utils/dist/validate-path.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
|
||||
var systemPath = require("path");
|
||||
|
||||
var mm = require("micromatch");
|
||||
|
||||
var tsDeclarationExtTest = /\.d\.tsx?$/;
|
||||
var jsonYamlExtTest = /\.(json|ya?ml)$/; // https://github.com/facebook/jest/blob/v24.0.0-alpha.4/packages/jest-config/src/Defaults.js#L71
|
||||
|
||||
function isTestFile(filePath) {
|
||||
var testPatterns = ["**/__tests__/**/*.(js|ts)?(x)", "**/(*.)+(spec|test).(js|ts)?(x)"];
|
||||
return mm.isMatch(filePath, testPatterns);
|
||||
}
|
||||
|
||||
module.exports = function (path) {
|
||||
// Disallow paths starting with an underscore (_) or dot (.)
|
||||
// and template-.
|
||||
// and .d.ts
|
||||
var parsedPath = systemPath.parse(path);
|
||||
return parsedPath.name.slice(0, 1) !== "_" && parsedPath.name.slice(0, 1) !== "." && parsedPath.name.slice(0, 9) !== "template-" && !tsDeclarationExtTest.test(parsedPath.base) && !jsonYamlExtTest.test(parsedPath.base) && !isTestFile(path);
|
||||
};
|
||||
50
node_modules/gatsby-page-utils/dist/watch-directory.js
generated
vendored
Normal file
50
node_modules/gatsby-page-utils/dist/watch-directory.js
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
||||
|
||||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
||||
|
||||
var Promise = require("bluebird");
|
||||
|
||||
var chokidar = require("chokidar");
|
||||
|
||||
var slash = require("slash");
|
||||
|
||||
module.exports =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
var _ref = (0, _asyncToGenerator2.default)(
|
||||
/*#__PURE__*/
|
||||
_regenerator.default.mark(function _callee(path, glob, onNewFile, onRemovedFile) {
|
||||
return _regenerator.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
||||
chokidar.watch(glob, {
|
||||
cwd: path
|
||||
}).on("add", function (path) {
|
||||
path = slash(path);
|
||||
onNewFile(path);
|
||||
}).on("unlink", function (path) {
|
||||
path = slash(path);
|
||||
onRemovedFile(path);
|
||||
}).on("ready", function () {
|
||||
return resolve();
|
||||
});
|
||||
}));
|
||||
|
||||
case 1:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this);
|
||||
}));
|
||||
|
||||
return function (_x, _x2, _x3, _x4) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}();
|
||||
76
node_modules/gatsby-page-utils/package.json
generated
vendored
Normal file
76
node_modules/gatsby-page-utils/package.json
generated
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
{
|
||||
"_from": "gatsby-page-utils@^0.0.5",
|
||||
"_id": "gatsby-page-utils@0.0.5",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-yHL4OKgVEOWOuTUCO2ZPPmWyA1bAtSUPrf+W5w3p24pUwqMkz2Yu2hii/PhgQs+2ap6BkpSwBjBSYS2YLRmTNg==",
|
||||
"_location": "/gatsby-page-utils",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "gatsby-page-utils@^0.0.5",
|
||||
"name": "gatsby-page-utils",
|
||||
"escapedName": "gatsby-page-utils",
|
||||
"rawSpec": "^0.0.5",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.0.5"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/gatsby-plugin-page-creator"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/gatsby-page-utils/-/gatsby-page-utils-0.0.5.tgz",
|
||||
"_shasum": "faefc2ece9f14bfd161ddd0104d1e12b54ef7a70",
|
||||
"_spec": "gatsby-page-utils@^0.0.5",
|
||||
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/gatsby-plugin-page-creator",
|
||||
"author": {
|
||||
"name": "Yvonnick FRIN",
|
||||
"email": "frin.yvonnick@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/gatsbyjs/gatsby/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.0.0",
|
||||
"bluebird": "^3.5.0",
|
||||
"chokidar": "2.1.2",
|
||||
"fs-exists-cached": "^1.0.0",
|
||||
"glob": "^7.1.1",
|
||||
"lodash": "^4.17.14",
|
||||
"micromatch": "^3.1.10",
|
||||
"slash": "^1.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Gatsby library that helps creating pages",
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.0.0",
|
||||
"@babel/core": "^7.0.0",
|
||||
"babel-preset-gatsby-package": "^0.2.2",
|
||||
"cross-env": "^5.0.5"
|
||||
},
|
||||
"files": [
|
||||
"dist/*"
|
||||
],
|
||||
"gitHead": "930533fccb1e172e01a40f2ce2a8a33d0b8e4d17",
|
||||
"homepage": "https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-page-utils#readme",
|
||||
"keywords": [
|
||||
"gatsby"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "dist/index.js",
|
||||
"name": "gatsby-page-utils",
|
||||
"peerDependencies": {
|
||||
"gatsby": "^2.0.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/gatsbyjs/gatsby.git",
|
||||
"directory": "packages/gatsby-page-utils"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel src --out-dir dist/ --ignore **/__tests__",
|
||||
"prepare": "cross-env NODE_ENV=production npm run build",
|
||||
"watch": "babel -w src --out-dir dist/ --ignore **/__tests__"
|
||||
},
|
||||
"version": "0.0.5"
|
||||
}
|
||||
Reference in New Issue
Block a user