Unbundeling a pre-built Javascript file built using browserify - browserify

I have a third party library, non uglified which was bundled using browserify. Unfortunately the original sources are not available.
Is there a way to unbundled it into different files/sources.

You should be able to 'unbundle' the pre-built Browserify bundle using browser-unpack.
It will generate JSON output like this:
[
{
"id": 1,
"source": "\"use strict\";\r\nvar TodoActions = require(\"./todo\"); ... var VisibilityFilterActions = require(\"./visibility-filter\"); ...",
"deps": {
"./todo": 2,
"./visibility-filter": 3
}
},
{
"id": 2,
"source": "\"use strict\";\r\n ...",
"deps": {}
},
{
"id": 3,
"source": "\"use strict\";\r\n ...",
"deps": {}
},
...
]
It should be reasonably straight-forward to transform the JSON output into source files that can be required. Note that the mappings of require literals (like "./todo") are in the deps. That is, the module required as "./todo" corresponds to the source with an id of 2.
There is also a browserify-unpack tool - which writes the contents as files - but I've not used it.

Related

How can i custom config CHANGELOG.md using standard-version npm package?

I'm using the command standard-version each time I want to publish new version, but the yielded changes in the CHANGELOG.md look like this:
### [10.1.9](https://github.com/my-project-name/compare/v10.1.8...v10.1.9) (2021-03-29)
### [10.1.8](https://github.com/my-project-name/compare/v10.1.7...v10.1.8) (2021-03-29)
### [10.1.7](https://github.com/my-project-name/compare/v10.1.6...v10.1.7) (2021-03-29)
first the links do not work - the github url is not correct and i want to configure it to the right url, and second, I'd like to configure the link that's shown in the changeslog file (there are some types)
I tried to use this documentation but didn't find anything that can help me
https://github.com/conventional-changelog/conventional-changelog
so how do I configure the way standard-version works on the CHANGELOG.md ? can someone provide example?
yes.
according to doc:
You can configure standard-version either by:
Placing a standard-version stanza in your package.json (assuming your project is JavaScript).
Creating a .versionrc, .versionrc.json or .versionrc.js.
If you are using a .versionrc.js your default export must be a configuration object, or a function returning a configuration object.
Any of the command line parameters accepted by standard-version can instead be provided via configuration.
Please refer to the conventional-changelog-config-spec for details on available configuration options.
example:
.versionrc
{
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "chore",
"hidden": true
},
{
"type": "docs",
"hidden": true
},
{
"type": "style",
"hidden": true
},
{
"type": "refactor",
"section": "Refactor"
},
{
"type": "perf",
"section": "Performance"
},
{
"type": "test",
"hidden": true
}
]
}

Libman copying folders from subdirectories but not root directory while using filesystem provider

I am using libman For managing client side libraries, and using the fileSystem provider.
Facing this issue:
{
"library": "Content/.",
"destination": "wwwroot/lib/animate/",
"files": [ "animate.css" ]
},
{
"library": "../../fonts/font-awesome/css",
"destination": "wwwroot/lib/font-awesome/",
"files": [ "font-awesome.css" ]
},
The font-awesome library is copied to the destination while the animate is not copied to the destination. The source libs exist.
I also tried Content instead of Content/. but this isn't working too. This issue is causing the build to fail as the BundlerMinifier.BundlerBuildTask is failing.
This is happening with other libs too like:
{
"library": "../../Scripts/.",
"destination": "wwwroot/lib/modernizr/",
"files": [ "modernizr-2.6.2.js" ]
}
What is the appropriate solution for this?

RequireJS script error when requiring "ReleaseaManagement/Core/RestClient" on TFS 2015 and 2017

I'm creating an tfs hub Extension (2015/2017) and need to read the projects' release defs and create releases also. I know, I could make direkt Rest Calls instead of using the methods of the rest clients. But they seem more comfortable to me.
When I try to get the Restmanagement RestClient, I get:
Script error for: ReleaseManagement/Core/RestClient
http://requirejs.org/docs/errors.html#scripterror
In both TFS.2015.2 and TFS.2017
Doesn't the client yet exist on-premise?
You can refer to this article for how to use Rest API in extension to read a release definition: Writing a ReleaseManagement extension for cloning an existing release definition.
The code to read a release definition:
VSS.require(["VSS/Controls", "VSS/Service", "ReleaseManagement/Core/RestClient"],
var rmClient = VSS_Service.getCollectionClient(RM_WebApi.ReleaseHttpClient);
rmClient.getReleaseDefinition(vsoContext.project.id,sourceItemContext.definition.id);
And if you are using typescript, you need to include "ms.vss-releaseManagement-web.release-service-data-external" in the contribution like following:
"contributions": [
{
"id": "release-status",
"type": "ms.vss-web.hub",
"includes": [ "ms.vss-releaseManagement-web.release-service-data-external" ],
"description": "A hub to show release status",
"targets": [
"ms.vss-work-web.work-hub-group"
],
"properties": {
"name": "hello",
"order": 99,
"uri": "app.html"
}
}
]

Bigcommerce stencil what is customLayouts used for?

I noticed that after using the command stencil init to generate a .stencil file for a new stencil project, the generate file contains a customLayouts attribute. For example, the file might contain this:
{
"normalStoreUrl": "http://www.my-store.com",
"port": 3000,
"username": "Stencil",
"token": "11223344556677889900",
"customLayouts": {
"products": {},
"search": {},
"brands": {},
"categories": {}
}
}
Can someone please explain the purpose of this customLayout object and how it can be used?
It isn't presently in use. It will be available for use to have customized templates per each of those types of pages once we have finished some engineering work. It is a placeholder at this time.

How to get revision history of a file using OneDrive for business API

I am integrating OneDrive for business (REST API) with our Platform. I can upload a file and update the files contents using the upload API. But how do I get the revision history of a file. The API which I am using is listed below.
Upload a file
You can't use OneDrive for business API to get file revisions (versions), but you can use SharePoint API to get them.
Use this link to get file versions:
GET
"https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/_api/web/GetFileByServerRelativeUrl(#v)/Versions?#v='/personal/email_tenant_onmicrosoft_com/Documents/TEST_005.xlsx'"
where:
"email_tenant_onmicrosoft_com" - is email of your drive
"tenant-my.sharepoint.com" - EndPoint of your drive
Response of this link looks like this JSON:
{
"odata.metadata": "https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/_api/$metadata#SP.ApiData.FileVersions",
"value": [
{
"odata.type": "SP.FileVersion",
"odata.id": "https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/_api/SP.FileVersionf1111111-aaaa-1234-5678-90abcdef1234",
"odata.editLink": "SP.FileVersionf1111111-aaaa-1234-5678-90abcdef1234",
"CheckInComment": "",
"Created": "2013-04-27T15:57:57Z",
"ID": 512,
"IsCurrentVersion": false,
"Length": "5716",
"Size": 5716,
"Url": "_vti_history/512/Documents/TEST_005.xlsx",
"VersionLabel": "1.0"
},
{
"odata.type": "SP.FileVersion",
"odata.id": "https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/_api/SP.FileVersion2ab46e3e-9614-43ff-ad03-252b1f4d0d90",
"odata.editLink": "SP.FileVersion2ab46e3e-9614-43ff-ad03-252b1f4d0d90",
"CheckInComment": "",
"Created": "2013-04-27T15:58:39Z",
"ID": 1024,
"IsCurrentVersion": false,
"Length": "7868",
"Size": 7868,
"Url": "_vti_history/1024/Documents/TEST_005.xlsx",
"VersionLabel": "2.0"
},
{
"odata.type": "SP.FileVersion",
"odata.id": "https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/_api/SP.FileVersion42f5f367-05ca-4131-84bf-79e7a6c0f77d",
"odata.editLink": "SP.FileVersion42f5f367-05ca-4131-84bf-79e7a6c0f77d",
"CheckInComment": "",
"Created": "2013-04-27T15:58:43Z",
"ID": 1536,
"IsCurrentVersion": false,
"Length": "7868",
"Size": 7868,
"Url": "_vti_history/1536/Documents/TEST_005.xlsx",
"VersionLabel": "3.0"
}
]
}
important parameters for you is:
"odata.editLink" after "SP.FileVersion" - it's unique Id of file version.
"ID" - it's version id of current file.
To download file version you can use this link:
"https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/_api/web/GetFileByServerRelativeUrl(#v)/Versions(1024)/$value?#v='/personal/email_tenant_onmicrosoft_com/Documents/TEST_005.xlsx'"
where "1024" - field "ID" from JSON.
To get info about last version of item you can use this link:
GET
"https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/_api/web/GetFileByServerRelativeUrl(#v)?#v='/personal/email_tenant_onmicrosoft_com/Documents/TEST_005.xlsx'"
Response of this link looks like this JSON:
{
"odata.metadata": "https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/_api/$metadata#SP.ApiData.Files12/#Element",
"odata.type": "SP.File",
"odata.id": "https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/_api/Web/GetFileByServerRelativeUrl('/personal/email_tenant_onmicrosoft_com/Documents/TEST_005.xlsx')",
"odata.editLink": "Web/GetFileByServerRelativeUrl('/personal/email_tenant_onmicrosoft_com/Documents/TEST_005.xlsx')",
"CheckInComment": "",
"CheckOutType": 2,
"ContentTag": "{C4B73433-8AED-44C2-862A-746EBA4599EB},11,7",
"CustomizedPageStatus": 0,
"ETag": "\"{C4B73433-8AED-44C2-862A-746EBA4599EB},11\"",
"Exists": true,
"IrmEnabled": false,
"Length": "7923",
"Level": 1,
"LinkingUri": "https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/Documents/TEST_005.xlsx?d=wc4b734338aed44c2862a746eba4599eb",
"LinkingUrl": "https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/Documents/TEST_005.xlsx?d=wc4b734338aed44c2862a746eba4599eb",
"MajorVersion": 4,
"MinorVersion": 0,
"Name": "TEST_005.xlsx",
"ServerRelativeUrl": "/personal/email_tenant_onmicrosoft_com/Documents/TEST_005.xlsx",
"TimeCreated": "2013-04-27T15:57:55Z",
"TimeLastModified": "2013-04-27T15:59:28Z",
"Title": null,
"UIVersion": 2048,
"UIVersionLabel": "4.0",
"UniqueId": "c4b73433-8aed-44c2-862a-746eba4599eb"
}
you can use this info, when you add a new revision of file.
"UniqueId" - it's right part of "odata.editLink" in versions JSON.
"UIVersion" - it's "ID" in version JSON.
To download last version of file - use this link:
"https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/_api/web/GetFileByServerRelativeUrl(#v)/$value?#v='/personal/email_tenant_onmicrosoft_com/Documents/TEST_005.xlsx'"
link:
"https://tenant-my.sharepoint.com/personal/email_tenant_onmicrosoft_com/_api/web/GetFileByServerRelativeUrl(#v)/Versions(2048)/$value?#v='/personal/email_tenant_onmicrosoft_com/Documents/TEST_005.xlsx'"
doesn't work. It will work if you add a new version of this file.
You can download last revision of item by using OneDrive API link:
"https://tenant-my.sharepoint.com/_api/v2.0/drives/driveId/items/driveItemId/content"
but this link doesn't work if you use Service Account authentication
Till date there is no api resource for getting version or revision history of a file. Follow the link to know about available operations on items in one drive for business.