@ms-cloudpack/path-string-parsing 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @ms-cloudpack/path-string-parsing
2
+
3
+ Common path-related string parsing utilities for Cloudpack.
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { safeRelativePath } from './safeRelativePath.js';
2
2
  export { slash } from './slash.js';
3
3
  export { parseImportString, type ImportStringResult } from './parseImportString.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,wBAAwB,CAAC"}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAA2B,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAA2B,MAAM,wBAAwB,CAAC","sourcesContent":["export { safeRelativePath } from './safeRelativePath.js';\nexport { slash } from './slash.js';\nexport { parseImportString, type ImportStringResult } from './parseImportString.js';\n"]}
@@ -1,6 +1,7 @@
1
- export declare type ImportStringResult = {
1
+ export type ImportStringResult = {
2
2
  packageName: string | undefined;
3
3
  version: string | undefined;
4
4
  importPath: string | undefined;
5
5
  };
6
6
  export declare function parseImportString(importString?: string): ImportStringResult;
7
+ //# sourceMappingURL=parseImportString.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseImportString.d.ts","sourceRoot":"","sources":["../src/parseImportString.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,YAAY,SAAK,GAAG,kBAAkB,CAWvE"}
@@ -1 +1 @@
1
- {"version":3,"file":"parseImportString.js","sourceRoot":"","sources":["../src/parseImportString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAQzD,MAAM,UAAU,iBAAiB,CAAC,YAAY,GAAG,EAAE;IACjD,MAAM,OAAO,GACX,YAAY,CAAC,KAAK,CAChB,wGAAwG,CACzG,IAAI,EAAE,CAAC;IAEV,OAAO;QACL,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG;QAC9B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE;QACzB,UAAU,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;KACzC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"parseImportString.js","sourceRoot":"","sources":["../src/parseImportString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAQzD,MAAM,UAAU,iBAAiB,CAAC,YAAY,GAAG,EAAE;IACjD,MAAM,OAAO,GACX,YAAY,CAAC,KAAK,CAChB,wGAAwG,CACzG,IAAI,EAAE,CAAC;IAEV,OAAO;QACL,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG;QAC9B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE;QACzB,UAAU,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;KACzC,CAAC;AACJ,CAAC","sourcesContent":["import { safeRelativePath } from './safeRelativePath.js';\n\nexport type ImportStringResult = {\n packageName: string | undefined;\n version: string | undefined;\n importPath: string | undefined;\n};\n\nexport function parseImportString(importString = ''): ImportStringResult {\n const matches =\n importString.match(\n /[/]?(@[-_a-z-A-Z0-9.]+\\/[-_a-z-A-Z0-9.]+|[-_a-zA-Z0-9.]+)(@([-_a-zA-Z-0-9.]+))?(\\/([-_/a-zA-Z0-9.]+))?/,\n ) || [];\n\n return {\n packageName: matches[1] || '.',\n version: matches[3] || '',\n importPath: safeRelativePath(matches[5]),\n };\n}\n"]}
@@ -2,3 +2,4 @@
2
2
  * Ensures the give relative path starts with a ./
3
3
  */
4
4
  export declare function safeRelativePath(originalPath: string | undefined): string;
5
+ //# sourceMappingURL=safeRelativePath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safeRelativePath.d.ts","sourceRoot":"","sources":["../src/safeRelativePath.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAezE"}
@@ -1 +1 @@
1
- {"version":3,"file":"safeRelativePath.js","sourceRoot":"","sources":["../src/safeRelativePath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,YAAgC;IAC/D,IAAI,CAAC,YAAY,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,IAAI,YAAY,KAAK,GAAG,EAAE;QACtE,OAAO,GAAG,CAAC;KACZ;IAED,oCAAoC;IACpC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;IAEnC,IAAI,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QAChC,OAAO,GAAG,GAAG,YAAY,CAAC;KAC3B;SAAM,IAAI,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QACxC,OAAO,YAAY,CAAC;KACrB;IAED,OAAO,KAAK,YAAY,EAAE,CAAC;AAC7B,CAAC"}
1
+ {"version":3,"file":"safeRelativePath.js","sourceRoot":"","sources":["../src/safeRelativePath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,YAAgC;IAC/D,IAAI,CAAC,YAAY,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,IAAI,YAAY,KAAK,GAAG,EAAE;QACtE,OAAO,GAAG,CAAC;KACZ;IAED,oCAAoC;IACpC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;IAEnC,IAAI,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;QAChC,OAAO,GAAG,GAAG,YAAY,CAAC;KAC3B;SAAM,IAAI,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QACxC,OAAO,YAAY,CAAC;KACrB;IAED,OAAO,KAAK,YAAY,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["import { slash } from './slash.js';\n\n/**\n * Ensures the give relative path starts with a ./\n */\nexport function safeRelativePath(originalPath: string | undefined): string {\n if (!originalPath || originalPath.length === 0 || originalPath === '.') {\n return '.';\n }\n\n // Ensure we have the right slashes.\n originalPath = slash(originalPath);\n\n if (originalPath.startsWith('/')) {\n return '.' + originalPath;\n } else if (originalPath.startsWith('./')) {\n return originalPath;\n }\n\n return `./${originalPath}`;\n}\n"]}
package/lib/slash.d.ts CHANGED
@@ -1 +1,3 @@
1
+ /** Replace backslashes with forward slashes. */
1
2
  export declare function slash(str: string): string;
3
+ //# sourceMappingURL=slash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slash.d.ts","sourceRoot":"","sources":["../src/slash.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEzC"}
package/lib/slash.js CHANGED
@@ -1,3 +1,4 @@
1
+ /** Replace backslashes with forward slashes. */
1
2
  export function slash(str) {
2
3
  return str.replace(/\\/g, '/');
3
4
  }
package/lib/slash.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"slash.js","sourceRoot":"","sources":["../src/slash.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,KAAK,CAAC,GAAW;IAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC"}
1
+ {"version":3,"file":"slash.js","sourceRoot":"","sources":["../src/slash.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,MAAM,UAAU,KAAK,CAAC,GAAW;IAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC","sourcesContent":["/** Replace backslashes with forward slashes. */\nexport function slash(str: string): string {\n return str.replace(/\\\\/g, '/');\n}\n"]}
@@ -1,11 +1,11 @@
1
- // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
- // It should be published with your NPM package. It should not be tracked by Git.
3
- {
4
- "tsdocVersion": "0.12",
5
- "toolPackages": [
6
- {
7
- "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.33.1"
9
- }
10
- ]
11
- }
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.35.2"
9
+ }
10
+ ]
11
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/path-string-parsing",
3
- "version": "1.0.0",
4
- "description": "Common string parsing of path utilities for the Cloudpack repo.",
3
+ "version": "1.0.2",
4
+ "description": "Common path-related string parsing utilities for Cloudpack",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "types": "./lib/index.d.ts",
@@ -13,7 +13,6 @@
13
13
  }
14
14
  },
15
15
  "scripts": {
16
- "api:update": "cloudpack-scripts api-update",
17
16
  "api": "cloudpack-scripts api",
18
17
  "build:watch": "cloudpack-scripts build-watch",
19
18
  "build": "cloudpack-scripts build",
@@ -24,9 +23,9 @@
24
23
  "test": "cloudpack-scripts test"
25
24
  },
26
25
  "devDependencies": {
27
- "@ms-cloudpack/eslint-config-base": "*"
26
+ "@ms-cloudpack/eslint-plugin-internal": "*"
28
27
  },
29
28
  "files": [
30
- "/lib"
29
+ "lib/**/!(*.test.*)"
31
30
  ]
32
31
  }
package/CHANGELOG.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "name": "@ms-cloudpack/path-string-parsing",
3
- "entries": [
4
- {
5
- "date": "Sat, 15 Oct 2022 08:11:07 GMT",
6
- "tag": "@ms-cloudpack/path-string-parsing_v1.0.0",
7
- "version": "1.0.0",
8
- "comments": {
9
- "major": [
10
- {
11
- "author": "dake.3601@gmail.com",
12
- "package": "@ms-cloudpack/path-string-parsing",
13
- "commit": "962ebd9eb867b159565e221c9f5e800a8eb0ec84",
14
- "comment": "Environment agnostic package with slash, parseImportString, and safeRelativePath."
15
- }
16
- ]
17
- }
18
- }
19
- ]
20
- }
package/CHANGELOG.md DELETED
@@ -1,13 +0,0 @@
1
- # Change Log - @ms-cloudpack/path-string-parsing
2
-
3
- This log was last generated on Sat, 15 Oct 2022 08:11:07 GMT and should not be manually modified.
4
-
5
- <!-- Start content -->
6
-
7
- ## 1.0.0
8
-
9
- Sat, 15 Oct 2022 08:11:07 GMT
10
-
11
- ### Major changes
12
-
13
- - Environment agnostic package with slash, parseImportString, and safeRelativePath. (dake.3601@gmail.com)
@@ -1 +0,0 @@
1
- export {};
@@ -1,43 +0,0 @@
1
- import { describe, it, expect } from '@jest/globals';
2
- import { parseImportString } from './parseImportString.js';
3
- describe(`parseImportString`, () => {
4
- it(`can parse a package import`, () => {
5
- expect(parseImportString('package')).toEqual({ packageName: 'package', version: '', importPath: '.' });
6
- });
7
- it(`can parse a package import with a scope`, () => {
8
- expect(parseImportString('@scope/package')).toEqual({
9
- packageName: '@scope/package',
10
- version: '',
11
- importPath: '.',
12
- });
13
- });
14
- it(`can parse a package import with a scope and path`, () => {
15
- expect(parseImportString('@scope/package/path/to/thing')).toEqual({
16
- packageName: '@scope/package',
17
- version: '',
18
- importPath: './path/to/thing',
19
- });
20
- });
21
- it(`can parse a package import with a scope, version, and path`, () => {
22
- expect(parseImportString('@scope/package@1234567890.1234567890.1234567890-abcdeABCDE/path/to/thing')).toEqual({
23
- packageName: '@scope/package',
24
- version: '1234567890.1234567890.1234567890-abcdeABCDE',
25
- importPath: './path/to/thing',
26
- });
27
- });
28
- it(`can handle package names with underscores`, () => {
29
- expect(parseImportString('package_name')).toEqual({
30
- packageName: 'package_name',
31
- version: '',
32
- importPath: '.',
33
- });
34
- });
35
- it(`can handle package names with dashes`, () => {
36
- expect(parseImportString('package-name')).toEqual({
37
- packageName: 'package-name',
38
- version: '',
39
- importPath: '.',
40
- });
41
- });
42
- });
43
- //# sourceMappingURL=parseImportString.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parseImportString.test.js","sourceRoot":"","sources":["../src/parseImportString.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACpC,MAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC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AE;YACX,UAAU,EAAE,GAAG;SAChB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- import { describe, it, expect } from '@jest/globals';
2
- import { safeRelativePath } from './safeRelativePath.js';
3
- describe('safeRelativePath', () => {
4
- it('can handle default import paths', () => {
5
- expect(safeRelativePath(undefined)).toEqual('.');
6
- expect(safeRelativePath('')).toEqual('.');
7
- expect(safeRelativePath('.')).toEqual('.');
8
- });
9
- it('can handle an absolute path', () => {
10
- expect(safeRelativePath('/foo/bar')).toEqual('./foo/bar');
11
- });
12
- it('can handle a relative path', () => {
13
- expect(safeRelativePath('./foo/bar')).toEqual('./foo/bar');
14
- });
15
- it('can handle a relative path without a leading slash', () => {
16
- expect(safeRelativePath('foo/bar')).toEqual('./foo/bar');
17
- });
18
- });
19
- //# sourceMappingURL=safeRelativePath.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"safeRelativePath.test.js","sourceRoot":"","sources":["../src/safeRelativePath.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjD,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACpC,MAAM,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC5D,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- export {};
package/lib/slash.test.js DELETED
@@ -1,8 +0,0 @@
1
- import { describe, it, expect } from '@jest/globals';
2
- import { slash } from './slash.js';
3
- describe('slash', () => {
4
- it('can reverse slashes', () => {
5
- expect(slash('\\asdf\\asdf/asdf')).toEqual('/asdf/asdf/asdf');
6
- });
7
- });
8
- //# sourceMappingURL=slash.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"slash.test.js","sourceRoot":"","sources":["../src/slash.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACrB,EAAE,CAAC,qBAAqB,EAAE,GAAG,EAAE;QAC7B,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}