オーストラリア政府の設計システムは廃止されており、詳細についてはコミュニティページをご覧ください
パンケーキは、フロントエンドでNPMを簡単に甘くするためのツールです。
NPMは、NPMを使用しようとするときにFrontend開発者が直面する課題について書きました。パンケーキは、個別にバージョンされた小さな独立したモジュールのアイデアを受け入れることにより、それらに対処しています。相互依存関係は、NPMが非常にうまく機能していることであり、パンケーキはそれらをフラットに保ち、競合についてエラーを発揮するのに役立ちます。ソリューションの詳細をご覧ください
Pancakeは競合を"peerDependencies"をチェックし、あなたのモジュールのコンテンツをコンパイルするプラグインが付属し、選択してインストールするために利用可能なすべてのモジュールをリストします。
パンケーキを使用して新しいプロジェクトを作成している場合は、独自のパンケーキモジュールの作成を検討する必要があります。
Pancakeには、オーストラリア政府の設計システムコンポーネントが搭載されています。 pancakeがインストールされているかどうかを知るには、 package.jsonファイルを"pancake": { ... }オブジェクトを確認してください。これがあり、出力を変更したい場合は、パンケーキ設定セクションをご覧ください。
ReactJSプロジェクトでSASS Globalsを使用することに問題がある場合は、例については、Design System React Starter Repoをご覧ください。
topに戻ります
~3.0.0package.jsonファイル( npm init --yesを実行)パンケーキだけでも依存関係はありませんが、すべてのプラグインは特定のバージョンへの依存関係を固定して、セキュリティへの影響を可能な限り低く抑えます。また、 package-lock.jsonファイルも発送します。
topに戻ります
パンケーキには、2つの異なるレベルの設定が付属しています。グローバルな設定は、プロジェクトに固有のプロジェクトやローカル設定にまたがることができます。
グローバル設定を変更するには、 --setフラグでパンケーキを実行します。
npx pancake --set [settingName] [value]| 設定 | 価値 | デフォルト |
|---|---|---|
npmOrg | これがNPM ORGスコープです | @gov.au |
plugins | プラグインを無効または有効にするためのスイッチ | true |
ignorePlugins | 無視されるプラグインの配列 | [] |
例:
npx pancake --set npmOrg yourOrgローカル設定を変更するには、 pancakeオブジェクトをpackage.jsonファイルに含めることだけです。すべての可能な設定を以下に示します。
{
"name" : "your-name" ,
"version" : "0.1.0" ,
"pancake" : { //the pancake config object
"auto-save" : true , //enable/disable auto saving the settings into your package.json after each run
"plugins" : true , //enable/disable plugins
"ignore" : [ ] , //ignore specific plugins
"css" : { //settings for the @gov.au/pancake-sass plugin
"minified" : true , //minify the css?
"modules" : false , //save one css file per module?
"browsers" : [ //autoprefixer browser matrix
"last 2 versions" ,
"ie 8" ,
"ie 9" ,
"ie 10"
] ,
"location" : "pancake/css/" , //the location to save the css files to
"name" : "pancake.min.css" //the name of the css file that includes all modules; set this to false to disable it
} ,
"sass" : { //settings for the @gov.au/pancake-sass plugin
"modules" : false , //save one Sass file per module?
"location" : "pancake/sass/" , //the location to save the Sass files to
"name" : "pancake.scss" //the name of the Sass file that includes all modules; set this to false to disable it
} ,
"js" : { //settings for the @gov.au/pancake-js plugin
"minified" : true , //minify the js?
"modules" : false , //save one js file per module?
"location" : "pancake/js/" , //the location to save the js files to
"name" : "pancake.min.js" //the name of the js file that includes all modules; set this to false to disable it
} ,
"react" : { //settings for the @gov.au/pancake-react plugin
"location" : "pancake/react/" , //the location to save the react files to; set this to false to disable it
} ,
"json" : { //settings for the @gov.au/pancake-json plugin
"enable" : false , //the pancake-json plugin is off by default
"location" : "pancake/js/" , //the location to save the json files to
"name" : "pancake" , //the name of the json file
"content" : { //you can curate what the json file will contain
"name" : true , //include the name key
"version" : true , //include the version key
"dependencies" : true , //include the dependencies key
"path" : true , //include the path key
"settings" : true //include the settings key
}
}
}
} jsを削除するには"name": false設定し、 minified値、 modules 、およびlocationを削除できます。
topに戻ります
pancake --helpを表示できます。
-n 、 --nosave
タイプ: <flag>
コマンドは、パンケーキがローカル設定の統合を停止し、デフォルトでそれらを完了し、それらをpackage.jsonに保存します。これにより、すべての設定が整理されるため、完全に再現できます。また、 "auds": { "auto-save": false }をpackage.jsonに追加することで、この動作をオプトアウトすることもできます。
npx pancake --nosave-o 、 --org
タイプ: <flag> [value]
このフラグを抑えることで、NPM ORGスコープを一時的に上書きすることができます。これは、テストに役立ちます。永続的な変更のために設定を使用してください。
npx pancake --org @otherOrg-p 、 --noplugins
タイプ: <flag>
すべてのプラグインを一時的に無効にすることができます。これは、CI統合に最適です。
npx pancake --noplugins-i 、 --ignore
タイプ: <flag> [comma separated list]
プラグインのリストを一時的に上書きすることができます。
npx pancake --ignore @gov.au/pancake-svg,@gov.au/pancake-js-v 、 --verbose
タイプ: <flag>
冗長愚かなモードでパンケーキを実行します。
npx pancake --verbosetopに戻ります
独自のモジュールでパンケーキを使用できます。モジュールでしなければならないのは、次のことです。
package.jsonファイルに追加しますpostinstallスクリプトと依存関係をpackage.jsonに追加します。JSONファイルパンケーキをインストールするには、ノードパッケージマネージャーを使用します。
npm i @gov.au/pancake
パンケーキが他の100 npmパッケージの中からモジュールを検出できるようにするには、 pancake-moduleオブジェクトをpancakeオブジェクトに追加する必要があります。
{
"name": "your-module-name",
"version": "1.0.0",
"description": "Your description",
+ "pancake": {
+ "pancake-module": { //pancake is looking for this object to id your module as a pancake module
+ "version": "1.0.0", //the major version of pancake
+ "plugins": [ //only state the plugins you need here
+ "@gov.au/pancake-sass"
+ ],
+ "org": "@gov.au @nsw.gov.au", //the npm organisations that will be searched for pancake modules
+ "sass": { //sass plugin specific settings
+ "path": "lib/sass/_module.scss", //where is your sass
+ "sass-versioning": true //enable sass-versioning. Read more here: https://github.com/dominikwilkowski/sass-versioning
+ },
+ "js": { //js plugin specific settings
+ "path": "lib/js/module.js" //where is your js
+ },
+ "react": {
+ "location": "lib/js/react.js" //the location to move the react files to
+ }
+ }
+ },
"dependencies": {},
"peerDependencies": {},
"devDependencies": {},
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "",
"license": "ISC"
}パンケーキの魔法は、 postinstallスクリプト内にあります。パンケーキを依存関係として追加し、スクリプトを追加できるようにするには:
{
"name": "your-module-name",
"version": "1.0.0",
"description": "Your description",
"pancake": {
"pancake-module": {
"version": "1.0.0",
"plugins": [
"@gov.au/pancake-sass"
],
"sass": {
"path": "lib/sass/_module.scss",
"sass-versioning": true
},
"js": {
"path": "lib/js/module.js"
},
"react": {
"location": "lib/js/react.js"
}
}
},
"dependencies": {
+ "@gov.au/pancake": "~1"
},
"peerDependencies": {},
"devDependencies": {},
"scripts": {
+ "postinstall": "pancake"
},
"author": "",
"license": "ISC"
}これにより、インストール直後にパンケーキが実行され、リリース1.0.0の最新バージョンを常に入手できます。設定を変更する必要がある場合(可能性が非常に高い)、実際にこのプロジェクトをフォークする必要はありません。 postinstallスクリプトで実行する前に、これらの設定をグローバルに設定できます。
" postinstall " : " pancake --set npmOrg yourOrg && pancake "ピア依存関係を追加することは、 dependenciesとpeerDependenciesに同時に追加することを忘れない限り、簡単です。そうすれば、NPMがピア依存関係をインストールし、パンケーキは競合があるかどうかを確認できます。
{
"name": "your-module-name",
"version": "1.0.0",
"description": "Your description",
"pancake": {
"pancake-module": {
"version": "1.0.0",
"plugins": [
"@gov.au/pancake-sass"
],
"sass": {
"path": "lib/sass/_module.scss",
"sass-versioning": true
},
"js": {
"path": "lib/js/module.js"
},
"react": {
"location": "lib/js/react.js"
}
}
},
"dependencies": {
"@gov.au/pancake": "~1",
+ "@gov.au/core": "^0.1.0"
},
"peerDependencies": {
+ "@gov.au/core": "^0.1.0"
},
"devDependencies": {},
"scripts": {
"postinstall": "pancake"
},
"author": "",
"license": "ISC"
}これで、モジュールを公開してパンケーキの使用を開始する準備が整いました。
topに戻ります
やあ ?、
❤️このセクションを検討しているのが大好きです。フィードバックやプルリクエストを歓迎し、このプロジェクトに自分の時間を費やしていることについて非常に心地よいです。貢献をカウントするには、最初にコードを読んで、私たちの考えが何であるかを確認してください。私たちはあなたと同じことをします。
注:Windowsでこのプロジェクトを構築しようとしている場合は、管理者シェルを使用して有効になっているSymlinksでこのリポジトリをクローンする必要があります。
git clone -c core.symlinks=true https://github.com/govau/pancakeこのプロジェクトを実行するには、糸をインストールする必要があります。
yarn installyarn buildモジュールの1つで開発するには、内部で時計を実行します。
cd packages/pancake/
yarn watch src/フォルダー内のファイルのみを編集することを確認してください。 bin/フォルダー内のファイルは、トランスピラーによって上書きされます。
コーディングスタイルを見て、それに反対するのではなく、それで作業してください。 ?
topに戻ります
スコープ付きNPM組織に4つのテストモジュールを公開して、相互依存関係をテストし、冗長モードをオンにしてデバッグしました。各バージョンの内部にあるもののリストを以下に見つけます。
@gov.au/testmodule1
@gov.au/testmodule2
@gov.au/testmodule1 : ^15.0.0@gov.au/testmodule3
@gov.au/testmodule1 : ^15.0.0@gov.au/testmodule2 : ^19.0.0@gov.au/testModule4
@gov.au/testmodule1 : ^15.0.0多くのシナリオを採用し、パンケーキの出力を備品と比較するエンドツーエンドのテストスクリプトがあります。
また、JESTを使用した単体テストを使用します。
すべてのテストを実行するには、以下のコマンドを使用します。
npm testパンケーキは、ubuntu 16.04、Mac OS 10.11、10.12、およびWindows 10でテストされています。NPM3以下のすべてのノードバージョン:
v5.0.0v5.12.0v6.9.5v7.0.0v7.4.0v7.5.0v7.6.0v10.0.0topに戻ります
著作権(c)オーストラリア連邦。 MITの下でライセンスされています。
topに戻ります